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 ?
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();
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.
Do you mean different types in the same array? Could you write an example of the json string?
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.
I have send the attachment to support.
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.
could it be that the attachment is missing ?
I also answer to the support mail because we have issues with file uploads on the forum for the moment.
i did not receive the reply on my support mail with the attachment.
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.
Just a retry to upload the images.
Ok yes these [0..1] means it’s optional attributes so this can be the issue.
ok, yes i have changed the attributes so they are optional.
But i am still getting the same error, it says:
JSONToClass(): Expected Record as top level element but found Array.
You must be logged in to reply to this topic.