Answers for "for each python json"

1

for each python json

import json

def main():

    # create a simple JSON array
    jsonString = '{"key1":"value1","key2":"value2","key3":"value3"}'

    # 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()
Posted by: Guest on March-02-2020
0

loop through json array python

for restaurant in data['restaurants']:
    print restaurant['restaurant']['name']
Posted by: Guest on April-29-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language