Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • The keys in a Python dictionary must be unique. In other words, you can't have two or more items with the same key. I suggest that you make "revision" a list of dicts, and maybe rename it to "revisions". Alternatively, you could have keys like "revision0", "revision1", etc, but that wouldn't be pleasant to work with. Commented Mar 15, 2016 at 2:29
  • Actually, my 2nd suggestion may be the better option here, since you have no control over the creation of the JSON. As Paul Gowder mentions, you could modify the JSON text using regex substitution before you pass it Python's JSON parser. If you want help coding this it would be advisable to post some sample JSON data as text, rather than as a linked image. Commented Mar 15, 2016 at 2:43
  • 1
    This question shows how to parse such files using the json module: Python json parser allow duplicate keys. Commented Mar 15, 2016 at 3:02
  • Do you mean that I should read each line and if it is revision append it by revision1, revision2 and so on for each object? Commented Mar 15, 2016 at 3:02
  • Yes, that was my earlier suggestion, but take a look at the question I just linked to, which shows a better way. Commented Mar 15, 2016 at 3:05