on 2019 May 14 3:31 PM
Hi Experts,
I need to get an array of JSON format, but unable to achieve it using XML to JSON converter. Current output:
{"accounts":{"resourceId":"No reply","currency":"SEK","product":"Product","name":"Name","clearingNumber":"CLNum","bban":"Bban","_links":{"balances":"","transactions":""}}}
expected output:
{"accounts":[{"resourceId":"Test","currency":"000","product":"Medlemskonto","name":"000000","clearingNumber":"0000","bban":"00000","_links":{"balances":{"href":"v1/accounts/000000000/balances"},"transactions":{"href":"v1/accounts/000000/transactions"}}}]}
Can this be achieved using streaming option, on element node but I am getting the array as the table cannot be empty.
Hi ALl,
I was able to solve the issue. Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vaishali
If your XML payload has only 1 occurrence of accounts, then the standard XML-to-JSON converter will not automatically generate a JSON array for it. It only does so when the occurrence on the XML is more than 1.
If you need to "force" the accounts field to be a JSON array even when there is only 1 element inside it, then you need to use a custom XML-to-JSON conversion. You can try out using XML2JSONConverter in FormatConversionBean for CPI. Parameter arrayFieldList as detailed in this blog post provides you the option to "force" the field to be generated as a JSON array.
Regards
Eng Swee
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Eng Swee,
The occurrence of accounts is set to 1is to many. Please see below screen shot:
Settings I am trying to do in standard converter:xmltojsonconverter-setting.png but the error is :Table may not contain empty rows.
Is there something wrong that I am trying to achieve.
Best Regards,
Vaishali
Hi vaishali.applicon
I wasn't aware that the standard converter allows custom array conversion when using the Streaming feature (have never used that).
I tried it out and it seems to work fine. Can you try this few things just to find out if your error could be due to other issues:-
- Uncheck "Suppress JSON Root Element
- Ensure your namespace setup is correct in both the converter, and also the overall IFlow (under Runtime Configuration)
If it still does not work, please provide your XSD schema and the sample source payload.
Regards
Eng Swee
User | Count |
---|---|
71 | |
11 | |
10 | |
10 | |
10 | |
8 | |
7 | |
7 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.