Unable to Parse JSON object with double quotes

Viewed 62

I am unable to parse nested JSON with in double quotes here is sample object. Flatten do not getting "RawRequest" key due it quoted in double quotes although its valid json:

   "Business ID":"Sajidbutta",
   "Acout":"Saji_12"
   "Report": {
      "ReportPDF": {
      "RawRequest": "{ \"subcode\" : \"35656\", \"Hoppoes\" :\"Hello\" ,\"Hoppoes\":[{\"tsn\" : \"44544545\", \"title\" : \"Owner\"}] }"
    }    
   }
}
1 Answers

You have two issues.

First, you're missing a comma between "Saji_12" and "Report":

 "Acout":"Saji_12" "Report": 

The second one is that you're missing the escaping \ in front of the " in the JSON string. Consider the following

{
    "Business ID": "Sajidbutta",
    "Acout": "Saji_12",
    "Report": {
        "ReportPDF": {
            "RawRequest": "{  \"subcode\" : \"35656\", \"Hoppoes\" :\"Hello\" ,\"Hoppoes\":[{\"tsn\" : \"44544545\", \"title\" : \"Owner\"}] }"
        }
    }
}

If the "RawRequest" is meant to actually be a json, then the following is appropriate (note the lack of quotation marks after the RawRequest key:

{
    "Business ID": "Sajidbutta",
    "Acout": "Saji_12",
    "Report": {
        "ReportPDF": {
            "RawRequest": {
                "subcode": "35656",
                "Hoppoes": "Hello",
                "Hoppoes": [
                    {
                        "tsn": "44544545",
                        "title": "Owner"
                    }
                ]
            }
        }
    }
}

Note also the duplicate key "Hoppoes" :)

Related