I've got the following JSON object:
{
"a" : {
"0" : 2,
"1" : 4,
"3" : 6,
},
"b" : {
"2" : 8,
"1" : 10, /*note this key exists in "a" too*/
"4" : 12,
}
}
I'd like to generate the following object and then be able to extract an element from it like so:
{
"0" : 2,
"1" : 10,
"2" : 8,
"3" : 6,
"4" : 12,
}
Extraction: object->>'1'
should return '10'
Basically, I have two arrays with potentially overlapping keys and I want to merge the two, giving one array precedence.
How can I accomplish this? Ideally I'd call a function like arrayMerge(a, b)
and it gave 'a'
higher precedence than 'b'