[
{
"builtin_name": "custom_template",
"fields": [
{
"id": 10012,
"field_type": "OBJECT_SET",
"tooltip_text": "",
"name_plural": "",
"name_singular": "reference",
"backref_name": "reference",
"backref_tooltip_text": "",
"allow_multiple": false,
"allowed_otypes": [
"schema",
"table",
"attribute",
"user",
"groupprofile",
"groupprofile"
],
"options": null,
"builtin_name": null
},
{
"id": 8,
"field_type": "OBJECT_SET",
"tooltip_text": null,
"name_plural": "Stewards",
"name_singular": "Steward",
"backref_name": "Steward",
"backref_tooltip_text": null,
"allow_multiple": true,
"allowed_otypes": ["user", "groupprofile", "groupprofile"],
"options": null,
"builtin_name": "steward"
}
],
"id": 16,
"title": "Custom template"
},
{
"builtin_name": "new_template",
"fields": [
{
"id": 10011,
"field_type": "PICKER",
"tooltip_text": "",
"name_plural": "",
"name_singular": "status",
"backref_name": "",
"backref_tooltip_text": "",
"allow_multiple": false,
"allowed_otypes": null,
"options": [
{
"old_index": 0,
"article_id": null,
"tooltip_text": null,
"in_use": true,
"title": "Done"
}
],
"builtin_name": null
}
],
"id": 1899,
"title": "New Template"
}
]
Using this JSON object, I want to replace the fields list where id=16 and title=Custom template. I have already generated the object I want to use to the replacement.
Here's what I have tried, but didn't work:
i=0
jdata_copy = jdata #this is so I can compare
for t in jdata:
if(t["title"]=="Custom template" and t["id"]==16):
jdata_copy[i]["fields"] = repl_data
i+=1
I've looked around for a simple json replace but haven't found.
Appreciate some help.
Thanks!