Skip to content

Instantly share code, notes, and snippets.

@gogromat
Last active December 16, 2015 22:59
Show Gist options
  • Save gogromat/5511165 to your computer and use it in GitHub Desktop.
Save gogromat/5511165 to your computer and use it in GitHub Desktop.
Jason("sample", sample_data).sample.flatten().getJsonData();
// Default flattener behavior:
// Flattens both nested arrays and objects,
// uses . for array keys and object properties
[
{
"name": "Alexander",
"nickname": "GogromaT",
"studies.0": "Com Sci",
"studies.1": "Japanese",
"studies.2": "Photography",
"body.gender": "Male",
"body.height": "6.4\"",
"body.eyes": "Blue"
},
{
"name": "Constantine",
"nickname": "KA",
"likes.0": "TED Talks",
"likes.1": "Beer",
"likes.2": "Movies",
"likes.3": "Cars",
"owns.0.name": "car",
"owns.0.model": "Dodge Intrepid",
"owns.0.model_year": 2004,
"owns.1.name": "camera",
"owns.1.model": "Pentax X-5"
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment