Class JSONData

java.lang.Object
org.djutils.data.json.JSONData

public final class JSONData
extends Object
JSONData takes care of reading and writing of table data in JSON format. The reader and writer use a streaming API to avoid excessive memory use. The class can be used, e.g., as follows:
 DataTable dataTable = new ListDataTable("data", "dataTable", columns);
 Writer writer = new FileWriter("c:/data/data.json");
 JSONData.writeData(writer, dataTable);
 
The JSON document has the following structure:
 {
   "table": {
     "id": "tableId",
     "description": "table description",
     "class": "org.djutils.data.ListDataTable"",
     "columns": [
       {
         "nr": "0",
         "id": "time",
         "description": "time in [s]",
         "class": "org.djtils.vdouble.scalar.Time",
       },
       {
         "nr": "1",
         "id": "value",
         "description": "value [cm]",
         "class": "double",
       },
       {
         "nr": "2",
         "id": "comment",
         "description": "comment",
         "class": "java.lang.String",
       },
     ] 
   },
   "data": [
     [ { "0" : "2" }, { "1": "14.6" }, { "2" : "normal" } ],   
     [ { "0" : "4" }, { "1": "18.7" }, { "2" : "normal" } ],   
     [ { "0" : "6" }, { "1": "21.3" }, { "2" : "abnormal" } ]
   ]
 }
 
Copyright (c) 2020-2020 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djutils.org. The DJUTILS project is distributed under a three-clause BSD-style license, which can be found at https://djutils.org/docs/license.html.
Author:
Alexander Verbraeck, Peter Knoppers, Wouter Schakel