Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pick Value from Json
#4
I fixed your json, since what you posted isn't valid. So the path to the id might not be the same as whatever the real data is. This should be enough to get you going in the right direction, though.

Also, after this post, I'm going to move the thread somewhere more applicable, since this has nothing to do with Python News lol

>>> import json
>>> text = '''
... {
... "Attributes": {
... "accessories": [],
... "age": 32.0,
... "blur": {
... "blurLevel": "low",
... "value": 0.11
... },
... "occlusion": {
... "eyeOccluded": false,
... "foreheadOccluded": false,
... "mouthOccluded": false
... },
...
... "Id": "c8c21d40",
... "faceRectangle": {
... "height": 154,
... "left": 477,
... "top": 144,
... "width": 154
... }
... }
... }
... '''
>>> parsed = json.loads(text)
>>> parsed
{'Attributes': {'accessories': [], 'age': 32.0, 'blur': {'blurLevel': 'low', 'value': 0.11}, 'occlusion': {'eyeOccluded': False, 'foreheadOccluded': False, 'mouthOccluded': False}, 'Id': 'c8c21d40', 'faceRectangle': {'height': 154, 'left': 477, 'top': 144, 'width': 154}}}
>>> parsed['Attributes']['Id']
'c8c21d40'
Reply


Messages In This Thread
Pick Value from Json - by dataonmyview - Sep-24-2018, 11:53 AM
RE: Pick Value from Json - by Axel_Erfurt - Sep-24-2018, 01:29 PM
RE: Pick Value from Json - by wavic - Sep-24-2018, 02:16 PM
RE: Pick Value from Json - by nilamo - Sep-24-2018, 04:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How do I pick the right python in Linux env? MDRI 9 3,756 Jun-27-2020, 05:40 PM
Last Post: snippsat
  Python MySQL - How to pick column row data as variable? bharaths 1 4,283 Nov-02-2018, 12:08 PM
Last Post: bharaths
  BaseHTTPServer.HTTPServer pick-a-port? degenaro 1 2,532 Jul-05-2018, 08:36 PM
Last Post: gontajones
  Pick 3 Lotto Code? Python3 4 4,603 Sep-10-2017, 05:09 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020