简体   繁体   中英

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.

  1. How to pass json array object from on javascript adapter to another javascript adapter?

  2. How to pass json array object with Apostrophe from on javascript adapter to another javascript adapter?

  3. Is there a limit in the JSON size?

We have tried:

  1. To call the second javascript adapter from the first javascript adapter:

     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 :

     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:

     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 :

     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/10/17 22:06:04:703 MYT] 00000131 MFP.Logger java.lang.IllegalArgumentException: invalid type of element

For 2) test case: Able to pass the JSON.

For 3) test case: Unable to pass the 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"}]; line 1, column]

For 4) test case:

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"}]; line 1, column]

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. 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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM