I am aware of several open source java libraries that will convert XML to JSON.
However, I am looking for a library (or way) that will suppress the leading @ that is prepended to the element attribute. So, for example, given the JSON string below:
{ "description":
{ "@lang":"en-us",
"@maxlength":"500",
"#text":"Vitamin D Supplementation"
}
}
I would like to produce the following JSON string (notice the missing @ in front of "lang" and "maxlength"):
{ "description":
{ "lang":"en-us",
"maxlength":"500",
"#text":"Vitamin D Supplementation"
}
}
As far as I can tell, no libraries offer a way to do this. Maybe there is a way to accomplish this using Regex, though I would have to be careful of not stripping valid @ characters in data?
@fooand the child element(s)foo. You could certainly post-process the JSON to alter any dictionary keys that start with@, but then you need some other strategy to deal with collisions.{"foo":"hi","foo":{}}, you never get a chance to look at the two payloads because it isn't valid to have duplicate keys.