I am struggling with json-parsing in java.
Is there a possibility to generate a representation of a random, not standardised json file in java?
I tried to use gson but I didn't really understood if and how that might be possible.
So the jsonFile could look like this:
{
"id":16875,
"position":[1,2,5,7],
"metadata":{
"color":"blue",
"id": "84779jh",
"more":{ "some":"randomdata","absolutly":"noStructure"}
}
any key-value pairs are possible and the json file can be nested as much and as deep as it wants to. I need to get something like a java object out of it to be able to merge it with another json file. I just need the metadata part, the rest can be ignored.
So anybody any ideas how I could make that work? I would appreciate any helps :)
the json above merged with (this is the parent node, so we keep his id and position and just merge the metadata)
{
"id":16zut,
"position":[1,2,5,7],
"metadata":{
"color":"green",
"id": "84ergfujh",
"more":{
"some":"randomdata",
"even":"more",
"absolutly":"noStructure"
},
"tags":[1,2,3,4,6,8,f7,h,j,f]
}
would be:
{
"id":16zut,
"position":[1,2,5,7],
"metadata":{
"color":["blue", "green"],
"id": ["84779jh","84ergfujh]",
"more":{ "some":"randomdata","absolutly":"noStructure","even":"more"}
"tags":[1,2,3,4,6,8,f7,h,j,f]
}
Thanks in advance and have a nice day.