Iterating through a JSON object in Python

Category > PYTHON || Published on : Friday, January 29, 2021 || Views: 1861 || Iterating through a JSON object in Python


Here Pawan Kumar will explain how to Iterating through a JSON object in Python

import json

def main():

    # create a simple JSON array
    jsonString = '{"Name":"Raj","Name":"Kumar","Name":"Ramesh"}'

    # change the JSON string into a JSON object
    jsonObject = json.loads(jsonString)

    # print the keys and values
    for key in jsonObject:
        value = jsonObject[key]
        print("The key and value are ({}) = ({})".format(key, value))

    pass

if __name__ == '__main__':
    main()