I have a HTTP response with JSON content,
based on some condition i want to remove the key & value of a particular node within response which is basically by doing the JSON parsing (I have tried using the Boost::ptree & nlohmann library),
by doing that the control characters are getting removed as well, how can i avoid this issue..?
I have tried parsing it & removing the fields that needs to be removed, but along with it the control characters are also getting removed since it is going via the parsing to ptree (where the control chars are not retained), and once i write back the modified ptree back to string the control chars are not there & there is a big difference in the content length
here is the example
{
"firstName": "John",
"lastName": "Doe",
"dateOfBirth": "1985-07-15",
"ssn": "123-45-6789",
"address": {
"streetAddress": "123 Main St",
"city": "Anytown",
"state": "CA",
"postalCode": "12345"
},
"phoneNumbers": [
{
"type": "home",
"number": "555-555-5555"
},
{
"type": "work",
"number": "555-555-5556"
}
],
"email": "[email protected]"
}
this is the output i got,
{“address”:{“city”:”Anytown”,”postalCode”:”12345″,”state”:”CA”,”streetAddress”:”123 Main St”},”dateOfBirth”:”1985-07-15″,”email”:”[email protected]”,”firstName”:”John”,”lastName”:”Doe”,”phoneNumbers”:[{“number”:”555-555-5555″,”type”:”home”},{“number”:”555-555-5556″,”type”:”work”}],”ssn”:”123-45-6789″}
which has a reduced content length as 305 where as original content length is 325.
zeven is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.