liveBook · Manning

JSON

As explained in Build Your Own Robot: Using Python, CRICKIT, and Raspberry Pi

JSON is a text-based data-interchange format that represents structured values using objects, arrays, strings, numbers, booleans, and null.

JSON is a text-based format for exchanging structured data between the robot and network clients. It carries web-service responses and expected request data. section 5.5

Use JSON at both sides of a robot-control interface:

Reading a robot timestamp

A client receives b'{"stamp": "2022-11-28T14:31:08.859478"}', passes it to json.loads, and accesses the value with result['stamp']. section 5.6.1

>>> response = urlopen('http://robopi:8888/').read()
>>> response
b'{"stamp": "2022-11-28T14:31:08.859478"}'
>>> json.loads(response)
{'stamp': '2022-11-28T14:31:08.859478'}
>>> result = json.loads(response)
>>> result
{'stamp': '2022-11-28T14:31:08.859478'}
>>> result['stamp']
'2022-11-28T14:31:08.859478'

Inspect the complete REPL sequence from raw JSON bytes to a Python dictionary and extracted timestamp. section 5.6.1

How Build Your Own Robot: Using Python, CRICKIT, and Raspberry Pi covers it

How deep it goes
Demonstrates automatic response serialization, request encoding, byte responses, and json.loads parsing, without detailing the full format specification.
Examples
Uses timestamp dictionaries, success-status responses, and speed parameters in robot movement requests.
What it assumes
Assumes basic Python and HTTP interaction while demonstrating JSON parsing from raw response bytes.
What you can do after
Apply it via Python to parse web responses and send JSON-encoded movement parameters to robot services.
How it connects
Connects JSON with HTTP, web services, Tornado, Python, urllib, and robot movement controls.

Also explained in

Compare how 35 books explain JSON →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Your Own Robot: Using Python, CRICKIT, and Raspberry Pi. The section links point to the parts of the book it draws on.