I have a json data similar to below.
{
firstName: “firstNameValue”,
lastName: “lastNameValue”,
“id1”: “id1value”,
“id2”: {
“key”: “value”
}
}
id1 and id2 are some attributes. These values are not know in json.
Question 1). How do I select data if “key” == “certain_value”?
Question 2) How do I fetch “id1”, “id2” keys (and its values)
Question 3) is there any way I can Nth attribute in a json?
I am not sure 100% if this is what you are asking but I’ll take a stab
I think you are looking for OBJECT_PAIRS() to query attribute names and values. For example;
select * from default
where any i in object_pairs(default)
satisfies i.name=“attrib_name” and i.value=“attrib_value” end;
There is no ordering of the attrib in JSON standard, so Nth attrib can change as documents get returned.
-cihan
Thanks for certain leads. It gave me clues to look forward to possible solution.
My Data structure has date with time as “id1” mentioned below. I need to update this attribute name to +1 week based on certain criteria in where clause.
If it is not clear I shall make a sample json with date in it.
We have several date functions. Please see the documentation.