I have a JSON String, but I need to change the names of the keys. How can I do this? Is it possible to change them directly without parsing the JSON to a HashMap or something?
1 Answer
only via an ugly regex that might not be very successful -
{ "foo" : "bar", "bar" : "foo"}
is going to cause you problems.
I would parse to an object format (like hashmap as you suggest) - and then do your search and replace on that - I think that it will be much more accurate.
1 Comment
Christian Kuetbach
I don't beleave that a regex could work, because the key may also be an value. And the value should not be replaced.