Python Forum

Full Version: Simple Python Json Help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, I'm trying to use python to grab the "memberCount" value of this page
https://groups.roblox.com/v1/groups/42

Can someone help out? Should be pretty simple.
What have you tried so far?
It is very simple using the json module (json.loads()).
I know how to do basic json parsing but not when it's like this

{"id":42,"name":"Building","description":"Building, the cornerstone of Roblox.","owner":{"userId":80119,"username":"stravant","buildersClubMembershipType":3},"shout":null,"memberCount":542727}

I'm not too advanced so if anyone can help that would be appreciated. I tried simple ["id"]["memberCount"] stuff
import json

myInput = '{"id":42,"name":"Building","description":"Building, the cornerstone of Roblox.","owner":{"userId":80119,"username":"stravant","buildersClubMembershipType":3},"shout":null,"memberCount":542727}'

j = json.loads(myInput)
print(json.dumps(j, indent=4, sort_keys=True))
print('MemberCount: {}'.format(j['memberCount']))
Worked, thank you.