JSON preferred over XML for government APIs


As more agencies turn to application programming interfaces, or APIs, to repurpose their data for mobile applications and websites, they're forced to choose a data format. JavaScript Object Notation, or JSON, appears to be edging out Extensible Markup Language, or XML, in the battle for government developers' loyalty, according to panelists speaking on an Oct. 25 DigitalGov University webinar.

Bill Rankin, a computer specialist at the Census Bureau who helped craft the agency's recently released APIs, said the agency decided to use JSON because it typically has "a smaller footprint." The bureau took that a step further by listing column headers only once at the top of data sets, rather than repeating them within listed data, as is common when using JSON, said Rankin.

"This tends to be faster and uses less memory than the object-based storage that would be used for the XML," he said.

Ben Balter, a presidential innovation fellow working on the MyGov project, also prefers JSON. He said it lessens the amount of data needed to describe the data in a set.

"So, when you are building a mobile app or something like that, it's a lot easier to use JSON," he said.

But really, said Balter, getting the data out there is more important that what format is used, and the more heavyweight XML format is still okay. He said government API developers are often confronted with another decision: whether to use a standards-based approach with Simple Object Access Protocol, or SOAP, or the less standards-heavy and conceptually simpler Representative State Transfer, or REST.

"REST is really the way we're going," he said. Within REST the data can be presented both as JSON and XML, he added.

For more:
- go to the webinar page (includes speaker bios, slides and an archived webcast)

Related Articles:
NASA using challenges to craft APIs
Agency API maturity varies significantly
NRC identifies new mobile services, APIs