0

usually what we do is,

var1 = open('data.json')

var2 = json.load(var1)

But in my case, I have JSON format data inside a variable called var_json. How to use json.load on this?

  • If `var2` contains a JSON-formatted string, `json.loads(var2)` will parse it into a Python dictionary/array. – SkyPlayX Nov 26 '21 at 06:22
  • Possible Duplicate, https://stackoverflow.com/q/39719689/4985099 – sushanth Nov 26 '21 at 06:22
  • @SkyPlayX Thanks for the reply But json.load maintains that nested structure but json.loads isn't. – user17475933 Nov 26 '21 at 06:23
  • 1
    @user17475933 What do you mean by "maintains that nested structure"? Both methods parse JSON to a Python dictionary or array exactly like the JSON string is built. – SkyPlayX Nov 26 '21 at 06:25
  • @user17475933 - Can you add some data sample for see how failed `json.loads` ? – jezrael Nov 26 '21 at 06:26

0 Answers0