Skip to content
Advertisement

Merge two json files implementing a row in a specific position

I’ve 3 json files. The first one have only one sentence (file1.json):

JavaScript

The second one have only one sentence(file.json):

JavaScript

And the third one is a list of dictionaries (example.json)

JavaScript

And I want to insert the sentence of file1.json or file2.json just above "Person": "Alex" in example.json. I say file1.json or file2.json because only one exits depending on the circumstances.

I’ve tried this

JavaScript

But it’s difficult for me to insert that row wherever I want.

Advertisement

Answer

jsonmerge is not really intended to do that. I’m just guessing what you’re really trying to accomplish but I think you better just load the JSON via the Python internals and then form the desired JSON manually.

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement