I have a stream of data that has the same header structure, with differing currencies. And I want to group them into single JSONs by individual currencies and store them in an object store. The issue I'm having is that the dataflow is asynchronous, and will need to be appended onto what is stored into the object store.
An example: Say at 12:00GMT I receive these two, separate json objects
1:
"prices": {
header": {
"currency": "EUR"
},
"price":{
"productId":"0000A",
"value":"60.00"
}
}
2:
"prices":{
header": {
"currency": "GBP"
},
"price":{
"productId":"000AA",
"value":"20.00"
}
}
I save them in an object store with the currency as the key. Then at 12:30GMT I get the next two values:
3:
"prices":{
header": {
"currency": "GBP"
},
"price":{
"productId":"000BB",
"value":"27.00"
}
}
4:
"prices":{
header": {
"currency": "EUR"
},
"price":{
"productId":"0000B",
"value":"120.00"
}
}
I want the Object store to look like this, with the currency as the key for each:
EUR: "prices": {
header": {
"currency": "EUR"
},
"price":{
"productId":"0000A",
"amount":"60.00"
},
"price":{
"productId":"0000B",
"amount":"120.00"
}
}
GBP: "prices":{
header": {
"currency": "GBP"
},
"price":{
"productId":"000AA",
"amount":"20.00"
},
"price":{
"productId":"000BB",
"amount":"27.00"
}
}