New Breed of JSON Tools Closes the Gap with XML

By: Morpheus Data

As JSON’s popularity for web app development increases, the range of tools supporting the environment expands into XML territory. The key is to maintain the simplicity and other strengths of JSON while broadening the environment’s appeal for web developers.

JSON or XML? As with most programming choices, determining which approach to adopt for your web app’s server calls is not a simple “either-or” proposition.

JSON, or JavaScript Object Notation, was conceived as a simple, concise data format for encoding data structures in an efficient text format. In particular, JSON is less “verbose” than XML, according to InCadence Strategic Solutions VP Michael C. Daconta in an April 16, 2014, article on GCN.com.

Despite JSON’s efficiency, Daconta lists four scenarios in which XML is still preferred over JSON:

  • When you need to tag the data via markup, which JSON doesn’t support
  • When you need to validate a document before you transmit it
  • When you want to extend a document’s elements via substitution groups or other methods
  • When you want to take advantage of one of the many XML tools, such as XSLT or XPath

SOAP APIs and REST APIs are also not strictly either/or

One of JSON’s claims to fame is that it is so simple to use it doesn’t require a formal specification. George Anadiotis explains in a January 28, 2014, post on the Linked Data Orchestration site that many real-world REST-based JSON apps require schemas, albeit much different schemas than their SOAP-based XML counterparts.

 

The basic JSON-REST model decouples the client and server, which separates the app’s internal data representation from the wire format. Source: Safety Net

The most obvious difference is that there are far fewer JSON tools than there are XML tools. This is understandable considering that XML has been around for decades and JSON is a relative newcomer. However, JSON tools are able to reverse-engineer schemas based on the JSON fragments you arrange on a template. The tools’ output is then edited manually to complete the schema.

Anadiotis presents a five-step development plan for a JSON schema:

  1. Create sample JSON for exchanging data objects
  2. Use a JSON schema tool to generate a first-draft schema based on your sample JSON fragments
  3. Edit the schema manually until it is complete
  4. Use a visualization tool to create an overview of the schema (optional)
  5. Run a REST API metadata framework to provide the API’s documentation

Tool converts JSON to CSV for easy editing

JSON may trail XML in quantity and quality of available toolkits, but the developer community is working hard to close the gap. An example is the free JSON-to-CSV converter developed by Eric Mills of the Sunlight Foundation. The converter lets you paste JSON code into a box and then automatically reformat and recolor it in an easy-to-read table.

 

In this example, the JSON-to-CSV converter transforms JSON code into a table of data about Ohio state legislators. Source: Programmable Web

Mills’ goal in creating the converter was to make JSON “as approachable as a spreadsheet,” as Janet Wagner repots in a March 31, 2014, post on the Programmable Web site. While the converter is intended primarily as a teaching tool that demonstrates the potential of JSON as a driver of the modern web, Mills plans to continue supporting the converter if is used widely.

Conversely, if you’d like to convert Excel/CSV data to HTML, JSON, XML, and other web formats, take the free Mr. Data Converter tool out for a spin.