JSON (Javascript Object Notation) is all the rage in modern web applications and has taken over XML for storing data in streams thanks to how much it fits with the Javascript programming language. JSON is highly hierarchical in nature and defines several data types so that a consumer application knows upfront the type of data it is dealing with (with the notable exception of dates which remain application-specific).
(sample JSON)
{
"count":2,
"cache":false,
"environment":"live",
"remainingAccesses":231,
"data":[
{"date":"2013-12-09", "service":"Be On", "campaign_id":17088, "campaign_name":"DE Peek & Cloppenburg Review Urban Karaoke",
"project_id":119, "websites":3, "impressions":48, "views":1, "views_paid":0, "redirects":0, "playtoends":0},
{"date":"2013-12-09", "service":"Be On", "campaign_id":17280, "campaign_name":"DE Telekom Technischer Support",
"project_id":137, "websites":4, "impressions":189, "views":47, "views_paid":0, "redirects":2, "playtoends":9}
]
}
xlsgen 4.0 can import any JSON stream from a regular URL, a file or a memory buffer. A JSON stream can also be read by passing the URL directly to the workbook Open() method.
The import can be customized to provide styles on a per column basis.
xlsgen automatically infers hierarchies, cardinalities and what looks like a table set.
C/C++ code |
xlsgen::IXlsJSONImportPtr json = worksheet->Import->JSON;
xlsgen::IXlsStylePtr style = worksheet->NewStyle(); style->Pattern->BackgroundColor = 0xFFFF00; style->Font->Italic = TRUE;
json->Options->ColumnStyleByName[L"City"] = style; json->ImportFile(L"input\\jsonfile3.json");
|