Q:

how to check if json has a key python

import json
  if 'id' not in dest:
      dest['id'] = -1
    targetId = dest['id']
1
json_string = """{"a": 1, "b": 2, "c": 3}"""
a_dictionary = json.loads(json_string)

b_in_dict =  "b" in a_dictionary
0
b_in_dict =  "b" in a_dictionary
0

New to Communities?

Join the community