简体   繁体   English

如何将json数组对象从一个JavaScript适配器传递到另一个JavaScript适配器?

[英]How to pass json array object from one javascript adapter to another javascript adapter?

We're using MobileFirst Foundation 8.0.0.00-20160822-2140 deployed to WebSphere Application Server V8.5.5.5. 我们正在使用部署到WebSphere Application Server V8.5.5.5的MobileFirst Foundation 8.0.0.00-20160822-2140。

  1. How to pass json array object from on javascript adapter to another javascript adapter? 如何将JSON数组对象从JavaScript适配器传递到另一个JavaScript适配器?

  2. How to pass json array object with Apostrophe from on javascript adapter to another javascript adapter? 如何将带有Apostrophe的json数组对象从JavaScript适配器传递到另一个JavaScript适配器?

  3. Is there a limit in the JSON size? JSON大小有限制吗?

We have tried: 我们尝试过:

  1. To call the second javascript adapter from the first javascript adapter: 要从第一个javascript适配器调用第二个javascript适配器,请执行以下操作:

     var samplejsonarrayobject = [{a:"xxx",b:"yyy"},{c:"zzz",d:"aaa"}]; var res = MFP.Server.invokeProcedure({ adapter: "secondAdapter", procedure: "secondAdapterFunction", parameters: [samplejsonarrayobject] }); 
  2. To call the second javascript adapter from the first javascript adapter with stringify : 要使用stringify从第一个javascript适配器调用第二个javascript适配器:

     var samplejsonarrayobject = [{a:"xxx",b:"yyy"},{c:"zzz",d:"aaa"}]; var stringifysamplejsonarrayobject = JSON.stringy(samplejsonarrayobject); var res = MFP.Server.invokeProcedure({ adapter: "secondAdapter", procedure: "secondAdapterFunction", parameters: [stringifysamplejsonarrayobject] }); 
  3. To call the second javascript adapter from the first javascript adapter with a very large JSON file: 要使用非常大的 JSON文件从第一个javascript适配器调用第二个javascript适配器,请执行以下操作:

     var largesamplejsonarrayobject = [{a:"xxx",b:"yyy"}...................................{c:"zzz",d:"aaa"}]; var largestringifysamplejsonarrayobject = JSON.stringy(largesamplejsonarrayobject); var res = MFP.Server.invokeProcedure({ adapter: "secondAdapter", procedure: "secondAdapterFunction", parameters: [largestringifysamplejsonarrayobject] }); 
  4. To call the second javascript adapter from the first javascript adapter with a very large JSON with Apostrophe symbol : 要从第一个javascript适配器调用第二个javascript适配器,并使用带有Apostrophe符号的超大JSON:

     var apostrophesamplejsonarrayobject = [{a:"xx'x",b:"yyy"},{c:"zzz",d:"aaa"}]; var apostrophestringifysamplejsonarrayobject = JSON.stringy(apostrophesamplejsonarrayobject); var res = MFP.Server.invokeProcedure({ adapter: "secondAdapter", procedure: "secondAdapterFunction", parameters: [apostrophestringifysamplejsonarrayobject] }); 

Returned errors 返回的错误

For 1) test case: 对于1)测试用例:

[1/10/17 22:06:04:703 MYT] 00000131 MFP.Logger java.lang.IllegalArgumentException: invalid type of element [1/10/17 22:06:04:703 MYT] 00000131 MFP.Logger java.lang.IllegalArgumentException:元素类型无效

For 2) test case: Able to pass the JSON. 对于2)测试用例:能够传递JSON。

For 3) test case: Unable to pass the JSON. 对于3)测试用例:无法传递JSON。

Caused by: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('s' (code 115)): was expecting comma to seperate ARRAY entries at [Source : ['[{a:"xx'x",b:"yyy"},{c:"zzz",d:"aaa"}]; 由以下原因引起:com.fasterxml.jackson.core.JsonParseException:意外的字符(“ s”(代码115)):期望逗号在[来源:['[{a:“ xx'x”,b: “YYY”},{C: “ZZZ”,d: “AAA”}]; line 1, column] 第1行,第[栏]

For 4) test case: 对于4)测试用例:

Caused by: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('s' (code 115)): was expecting comma to seperate ARRAY entries at [Source : ['[{a:"xx'x",b:"yyy"},{c:"zzz",d:"aaa"}]; 由以下原因引起:com.fasterxml.jackson.core.JsonParseException:意外的字符(“ s”(代码115)):期望逗号在[来源:['[{a:“ xx'x”,b: “YYY”},{C: “ZZZ”,d: “AAA”}]; line 1, column] 第1行,第[栏]

Solve it by: 解决方法:

jsonString = replaceAllString(jsonString, "'s", "'s");

function replaceAllString(stringJ,search, replacement) {
    return stringJ.replace(new RegExp(search, 'g'), replacement);
}

This is indeed a defect and a regression from MobileFirst Platform Foundation 7.1. 这确实是一个缺陷,并且是MobileFirst Platform Foundation 7.1的回归。 The development team will be working on fixing this. 开发团队将致力于解决此问题。

To track this issue the following APAR has been opened: PI74759: CAN'T PASS A JSON OBJECT OR A JSON ARRAY AS A PARAMETER TO MFP.SERVER.INVOKEPROCEDURE 要跟踪此问题,已打开以下APAR:PI74759:无法将JSON对象或JSON数组作为参数传递给MFP.SERVER.INVOKEPROCEDURE

Update: Install the latest 8.0 iFix to obtain a fix for this issue, which resides on the server, so a new server installation is required. 更新:安装最新的8.0 iFix以获取针对此问题的修复程序,该修复程序位于服务器上,因此需要重新安装服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从数组和JavaScript中的另一个对象传递对象 - How to pass object from array and another object in javascript 如何将json数据从一个JavaScript传递到另一个 - How to pass json data from one javascript to another 如何从JavaScript适配器内部获取userIdentity? - How to get userIdentity from inside javascript adapter? JavaScript:如何将对象值从一个函数传递给另一个函数 - JavaScript: how to pass object value from one function to another 如何将javascript变量/对象从一页传递到另一页? - How to pass javascript variable/object from one page to another? 如何在 javascript 中将 object 从一个文件传递到另一个文件? - How to pass object from one file to another in javascript? 如何将Javascript对象从一个脚本传递到另一脚本? - How to pass Javascript object from one script to another script? 如何从 javascript 适配器调用 java 方法 - How to call java method from a javascript adapter 如何将动态字符串数组从javascript传递到JSON对象 - how to pass dynamic string array from javascript to JSON object 如何将json数据从一个JavaScript函数传递到另一个JavaScript函数? - How to pass json data from one javascript function to another javascript function?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM