Reading JSON attribute

You can read a JSON attribute as any other entity attribute:

  1. >>> Product[1].info
  2. {'battery': 3600, '3.5mm jack': True, 'colors': ['Black', 'Grey', 'Gold'],
  3. 'display': 5.5}

Once JSON attribute is extracted from the database, it is deserialized and represented as a combination of dicts and lists. You can use the standard Python dict and list API for working with the value:

  1. >>> Product[1].info['colors']
  2. ['Black', 'Grey', 'Gold']
  3. >>> Product[1].info['colors'][0]
  4. 'Black'
  5. >>> 'Black' in Product[1].info['colors']
  6. True