You can augment JSON key/value pairs for a JSON document in your collection using the join operation. This works similar to the datatools cli called jsonjoin.
In this example our collection is called people.ds. Let’s assume you have a record in your collection with a key ‘jane.doe’. It has three fields - name, email, age.
{"name":"Doe, Jane", "email": "jd@example.org", "age": 42}
You also have an external JSON document called profile.json. It looks like
{"name": "Doe, Jane", "email": "jane.doe@example.edu", "bio": "world renowned geophysist"}
You can merge the unique fields in profile.json with your existing jane.doe record
= "people.ds"
c_name = "jane.doe"
key = {"name":"Doe, Jane", "email": "jd@example.org", "age": 42}
profile # First create our object, then we'll join more data.
dataset.create(c_name, key, profile)= {"name": "Doe, Jane", "email": "jane.doe@example.edu", "bio": "world renowned geophysist"}
new_profile dataset.join(c_name, key, new_profile)
The result would look like
{"name":"Doe, Jane", "email": "jd@example.org", "age": 42, "bio": "renowned geophysist"}
If you wanted to overwrite the common fields you would use ‘join overwrite’
= True) dataset.join(c_name, key, new_profile, overwrite
Which would result in a record like
{"name":"Doe, Jane", "email": "jane.doe@example.edu", "age": 42, "bio": "renowned geophysist"}