Download - Data Formats

Transcript

Data Formats

By Subhash Chandran

Types

Storage

Integration and communication

Types

Binary

Text

Binary Formats

Costly to implement

Both systems should support same interfaces

Both should support the same version of the interfaces

Some Binary Formats

CORBA

RMI

COM

EAI

Some Text Formats

Strict text formats (think COBOL)

CSV

Ini

Java properties

XML

JSON

YAML

Strict text formats: Limitations

Each and every column to be defined precisely

The definition should be understandable by all participating applications

CSV

Good way to share tabular data

CSV Limitations

No one standard:

name,age\,,name,age\,,

Both the above are valid!

Ini Format

Two levels of hierarchy supported

Good parser support

ini format example

[key1]subkey1 = valuesubkey2 = value

[key2]subkey1 = valuesubkey2 = value

Java Properties

Well defined

No external library required for parsing

XML

Well defined

Has well defined set of complementing technologies: DTD, XML Schema, XSLT, XPath

Wide support in many programming languages

Any level of nesting

JSON

JavaScript Object Notation

JSON

Ease of parsing using JavaScript

Good for Ajax

JSON Examples

["python","java","ruby"]

{"python":"Guido van Rossum","php":"Rasmus Lerdorf","java":"James Gosling"}

Serialize Java Objects as JSON

Consume JSON in JavaScript: Arrays

Consume JSON in JavaScript: Map

YAML: YAML Aint Markup Language

american: - Boston Red Sox - Detroit Tigers - New York Yankeesnational: - New York Mets - Chicago Cubs - Atlanta Braves

When to use what?

IniTwo level hierarchy.JSONWhen JavaScript consumes your content.Ajax applications.XMLAll cases!YAMLHuman editing is needed.

Thanks :-)