JSON Syntax Doctor¶
Run the JSON Syntax Doctor MicroSim Fullscreen
You can include this MicroSim on your website using the following iframe:
<iframe src="https://dmccreary.github.io/robot-arm/sims/json-syntax-doctor/main.html"
height="606px" width="100%" scrolling="no"></iframe>
Description¶
Judge six short JSON settings files against five JSON rules: mark the line that breaks a rule and name the rule, or decide that the file is valid. Used in Chapter 1.
The file is shown with line numbers, in plain black text. There is no syntax coloring, so color never gives the mistake away. The five rules from the chapter are listed as A to E.
Files 1 to 5 each break exactly one rule on exactly one line. File 6 is valid. The values /dev/ttyACM0 and 1000000 are example settings, and each file was checked by loading it with the json module of Python 3.13.
Lesson Plan¶
Grade level: Middle school and up (age 12+). Time: 5 to 10 minutes.
- Read the file against the rules. Go down the rule list A to E and ask of each line: does it break this rule?
- Commit a judgment. Click the line that breaks a rule, click the rule, and press Check. If nothing is wrong, click No error instead. You get one attempt per file, and both the line and the rule must be right.
- Read the reason. The bad line and the rule turn green, and the feedback explains the mistake.
- Review. The last screen lists all six verdicts. Mastery is 5 of 6.
- Think about it. In file 3 the parser complains about line 3, but the fix goes on line 2. Why?
Specification¶
The learning objective, evidence of mastery and content for this MicroSim are specified in Chapter 1: Setting Up Python for Robotics.
References¶
- json: JSON encoder and decoder - Python Standard Library documentation - How Python loads a JSON file and the JSONDecodeError it raises for a syntax mistake.
- Introducing JSON - json.org - The complete JSON grammar on one page.