how to count number of records in json 1

how to count number of records in json

'''
USE len() TO COUNT THE ITEMS IN A JSON OBJECT
Call len(obj) to return the number of items in a JSON object obj.
'''

print(a_json_object)
'''OUTPUT:													'''
'''{'first_key': [1, 2, 3], 'second_key': 'second_value'}	'''
length = len(a_json_object)

print(length)
'''OUTPUT:													'''
'''2														'''

Here is what the above code is Doing:
1. We create a JSON object called a_json_object.
2. We call len() on a_json_object and store the result in length.
3. We print length.

Similar Posts