I've been trying to format my JSON file and convert it to XML, but I keep running into errors. Here's the JSON I have:
"_source": {
"@timestamp": "2026-03-18T12:00:01Z",
"extcompid": "143-1289",
"loglevel": "INFO",
"content": "(\"requeststatus\":{\"issuccess\":\"true\",\"invoice\":[{
\"requeststatus\":{
\"issuccess\":\"true","ispartialsuccess\":\"false\"},
\"calcdirection\":\"forward",
\"compid\":\"143-1289"
}]n}
}
Can anyone help me figure out what I'm doing wrong?
3 Answers
First off, have you actually checked the error message? It's super helpful to include it here so others can help you troubleshoot better. But looking at your JSON, there are definitely some escaping issues. The content field is particularly messy with mixed escaped and unescaped quotes. Clean up those backslashes to ensure your nested JSON structure is valid before you even think about converting it to XML! Also, a quick tip: try pasting your JSON into a validator like jsonlint.com; it'll highlight exactly where things are going wrong!
About the XML conversion, know that JSON doesn’t convert to XML easily due to structural differences. You need a clear strategy for translating JSON children into XML attributes or child elements. But before anything, ensure your JSON is valid, or you'll run into more headaches down the line!
Your JSON really needs to start with a "{" and end with a "}". Also, make sure you have those escape characters (``) before the quotes in properties like `issuccess` and `ispartialsuccess`. The opening parenthesis in the `content` string is funky, too, but it won’t break JSON validation unless you try to deserialize it on its own. If it keeps causing problems, try temporarily removing the content part of the JSON to focus on fixing the main structure first.

Yeah, it's like when someone says their car won't start without mentioning basic stuff like whether it has gas or if there's smoke. Go easy on yourself and just simplify the JSON first to identify issues, then gradually add parts back in.