bildwelt
E2E FORUM
E2E Bridge E2E Commerce

json response message with arrays

E2E Forum Modeling & Development json response message with arrays

This topic contains 19 replies, has 3 voices, and was last updated by  e2eforum-admin 1 year, 8 months ago.

Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #2245

    marcusr
    Participant

    I am trying to parse a json response message which contains a array at top level with several elements which also contain an array.
    I have created a xml class as target object but i am not able to set the target with the jsontoclass operation. What do i need to to do in order to get this working ?

    #2261

    Cyril
    Moderator

    You only need to create an objet of the target type and set it using jsonToClass. In your case the object would be an array (with stereotype <<E2EArray>>) with your type as arrayElement. Then the action script will look like this:

    
    create resultArray;
    set resultArray = jsonString.jsonToClass();
    
    #2262

    marcusr
    Participant

    Yes, i have tried that.
    But the json string contains complex types within the element of an array.
    I have tried several ways to fix this, but no success yet.

    #2263

    Cyril
    Moderator

    Do you mean different types in the same array? Could you write an example of the json string?

    #2264

    marcusr
    Participant

    I have added the model on which the response message is based. also i have added an example of a single response and of multiple entries.
    The message which contains the multiple entries is the one i try to process.

    #2265

    marcusr
    Participant

    again

    #2266

    marcusr
    Participant

    I have send the attachment to support.

    #2267

    Cyril
    Moderator

    There should not be any issue with this model structure. I attach an example of model and activity. I didn’t put all attributes I guess the issue is on parts

    If this is what you did could you write the error you get.

    #2268

    marcusr
    Participant

    could it be that the attachment is missing ?

    #2269

    Cyril
    Moderator

    I also answer to the support mail because we have issues with file uploads on the forum for the moment.

    #2270

    marcusr
    Participant

    i did not receive the reply on my support mail with the attachment.

    #2271

    marcusr
    Participant

    Sorry, my mistake. you are refering to the images in the reply.
    I did not use the [0..1] with each attribute but just string.
    I will try this and let you know the outcome.

    #2272

    Cyril
    Moderator

    Just a retry to upload the images.

    #2273

    Cyril
    Moderator

    Ok yes these [0..1] means it’s optional attributes so this can be the issue.

    #2274

    marcusr
    Participant

    ok, yes i have changed the attributes so they are optional.
    But i am still getting the same error, it says:

    bridge:External/JSONSM/5
    JSONToClass(): Expected Record as top level element but found Array.

Viewing 15 posts - 1 through 15 (of 20 total)

You must be logged in to reply to this topic.