I can have JSON like this:
[
{
"number": 123,
"items" : [
{"product": "P1","cost":10.5},
{"product": "P2","cost":5.25}
],
"tags":["a","b","c"],
"customer": {
"name": "Roberto",
"shortName": "Beto"
},
"actions": [{
"moment": "2021-01-01 11:22:22.222",
"description": "action 1"
},{
"moment": "2021-01-23 11:22:22.222",
"description": "action 2"
}]
}
]
I need to get outputs like a SQL result of a query using joins
. Note that the output must be coordinated based on the complex associations (in the case above, the properties: items and actions):
[
{ "number": 123, "items_product" : "P1", "items_cost": 10.5, "tags": null, "actions_moment": null, "actions_description": null}
{ "number": 123, "items_product" : "P2", "items_cost": 5.25, "tags": null, "actions_moment": null, "actions_description": null}
{ "number": 123, "items_product" : null, "items_cost": null, "tags": "a", "actions_moment": null, "actions_description": null}
{ "number": 123, "items_product" : null, "items_cost": null, "tags": "b", "actions_moment": null, "actions_description": null}
{ "number": 123, "items_product" : null, "items_cost": null, "tags": "c", "actions_moment": null, "actions_description": null}
{ "number": 123, "items_product" : null, "items_cost": null, "tags": null, "actions_moment": "2021-01-01 11:22:22.222", "actions_description": "Expedicao"}
{ "number": 123, "items_product" : null, "items_cost": null, "tags": null, "actions_moment": "2021-01-23 11:22:22.222", "actions_description": "Bla bla bla"}
]
I need to generate output dynamically using Java and Google Gson.