I have some arbitrary Json and I want to replace some of the text fields with objects. The text fields have a certain pattern, for example, say they start with a dollar sign $. I have no idea in advance what the keys are.
The object I want to replace it with is a Pojo probably a Map or List, which can be easily serialized to Json
For example
{
"key1" : "some value",
"key2" : "$replaceMe",
"key3" : {
"key4" : "more complex",
"key5" : "$andMe"
}
So after the replacement, the object would look something like this
{
"key1" : "some value",
"key2" : {},
"key3" : {
"key4" : "more complex",
"key5" : {}
}
where {}
represents the new object that replaced the string that was previously there
I figured out several ways to traverse the tree, but can't figure out a good way to keep track of the objects to be replaced and how to replace them.