Created on 06-25-2018 07:28 PM - edited 08-17-2019 05:21 PM
Hello,
I am taking data in xml format using SOAP-Request.
I convert the incoming xml data to json format through the Stylesheet XML file using the TransformXML processor.
but in the json file that is created after the conversion, I am getting the wrong json format warning because I am marked as yellow ".
incorrect
{ "soap:Envelope": { "soap:Body": { "Musteri_Hiyerarsi_TablosuResponse": { "Musteri_Hiyerarsi_TablosuResult": "[ { "UNIQ_KEY": 740281.0, "TTALT": 112.0, "TTAD": "TEST" } ]" } } } }
"sign cleared
{ "soap:Envelope": { "soap:Body": { "Musteri_Hiyerarsi_TablosuResponse": { "Musteri_Hiyerarsi_TablosuResult": [ { "UNIQ_KEY": 740281.0, "TTALT": 112.0, "TTAD": "TEST" } ] } } } }
I ask you for your help on how to remove the character.
ek'te
thank you.
Created on 06-26-2018 01:36 AM - edited 08-17-2019 05:20 PM
You can use ReplaceText processor after TransformXml processor then add the matching regex excluding "(quotes) before/after array [].
ReplaceText Configs:-
Search Value
(.*)"(\[.*\])"(.*)
Replacement Value
$1$2$3
Character Set
UTF-8
Maximum Buffer Size
1 MB //increase the size according to your flowfile size
Replacement Strategy
Regex Replace
Evaluation Mode
Entire text
Input:-
{ "soap:Envelope": { "soap:Body": { "Musteri_Hiyerarsi_TablosuResponse": { "Musteri_Hiyerarsi_TablosuResult": "[ { "UNIQ_KEY": 740281.0, "TTALT": 112.0, "TTAD": "TEST" } ]" } } } }
Output: valid json
{ "soap:Envelope": { "soap:Body": { "Musteri_Hiyerarsi_TablosuResponse": { "Musteri_Hiyerarsi_TablosuResult": [ { "UNIQ_KEY": 740281.0, "TTALT": 112.0, "TTAD": "TEST" } ] } } } }
Created 06-27-2018 04:02 AM
Could you share your sample xml file data so that i can reproduce the issue on my side by converting to json format?
Created 06-28-2018 09:23 AM
hello,
ReplaceText process data did not work on large data.
I am posting a larger example of the data in the attachment.
If you can help it very much but very much.xml-to-json.zip
Created 06-29-2018 09:29 AM
As your xml doc having array [] in it and i'm not sure how to write matching xslt. As the current xslt converts the array xml into object/element and adding "" for array[].
In case of large data you have to increase the
Maximum Buffer Size
1 MB //increase based on your flowfile size
as this processor works takes the whole flowfile into memory and does all replacing based on our configs.
Created 06-26-2018 05:04 AM
thank you for your help. it worked. but as an example I rolled this json format. Normally it will be over 100mb. the error is still the same.But this solution can be a quick solution. can not you do anything to correct this problem in the incoming xml file Stylesheet? note: I have not been able to experiment on large data yet because it is in the test phase.
Created 06-27-2018 05:34 AM
Created 06-27-2018 06:13 AM
This is the best steps to resolve the problem with the XML. you can resolve the problem in nifi. And if you are using any home appliances like fridge and washing machine then you can coordinate with geek squad support UK 24*7.