January 2013
Intermediate to advanced
328 pages
8h 5m
English
Lots of web services return JSON data, and we might run into a situation where we want to feed some JSON data into existing code that accepts only XML. Let’s use our JSON grammar from Parsing JSON as a foundation to build a JSON to XML translator. Our goal is to read in JSON text like this:
| | { |
| | "description" : "An imaginary server config file", |
| | "logs" : {"level":"verbose", "dir":"/var/log"}, |
| | "host" : "antlr.org", |
| | "admin": ["parrt", "tombu"], |
| | "aliases": [] |
| | } |
and emit XML in an equivalent form, like this:
| | <description>An imaginary server config file</description> |
| | <logs> |
| | <level>verbose</level> |
| | <dir>/var/log</dir> |
| | </logs> |
| | <host>antlr.org</host> ... |
Read now
Unlock full access