• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
      • Statement Format Symbols
      • Alphabetical List of Functions and Statements
      • List of Reserved Words
      • Deprecated Features
      • Declaration Statements
      • Numeric Values
      • String Values
      • Symbol Functions
      • Item Functions
      • Array Object
      • Audio Object
      • Barcode and QR Codes
      • Case Object
      • Document Object
      • File Object
      • Freq Object
      • Geometry Object
        • Geometry Statement
        • Geometry.area Function
        • Geometry.clear Function
        • Geometry.load Function
        • Geometry.maxLatitude Function
        • Geometry.maxLongitude Function
        • Geometry.minLatitude Function
        • Geometry.minLongitude Function
        • Geometry.perimeter Function
        • Geometry.save Function
        • Geometry.tracePolygon Function
        • Geometry.walkPolygon Function
        • Geometry.getProperty Function
        • Geometry.setProperty Function
        • JSON Representation
      • HashMap Object
      • Image Object
      • List Object
      • Map Object
      • Path
      • Pff Object
      • StringWriter Object
      • SystemApp Object
      • ValueSet Object
      • Program Control Statements
      • Assignment Statements
      • Data Entry Statements and Functions
      • Batch Edit Statements
      • Numeric Functions
      • String Functions
      • Multiple Occurrence Functions
      • General Functions
      • Date and Time Functions
      • External File Functions
      • Synchronization Functions
    • Text Templates
    • Templated Reporting System
    • HTML, Markdown, and JavaScript Integration
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataManager>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

CSPro ⇄ JSON Conversions: Geometry Object

A CSPro Geometry object is represented as a JSON object with "metadata" and "content" properties. Based on JSON serialization options—defined as an application property or dynamically—the value of the logic object or dictionary item can be serialized either as a data URL or as a localhost URL.
When using Geometry.getJson on a Geometry specified as a dictionary item, additional properties, "item" and "occurrences", give information about the dictionary item's properties as well as details about the item's occurrences.
For example, serializing a Geometry dictionary item, PARK_PATH, to JSON using the default way of representing the binary data as a localhost URL, may look like:
PARK_PATH.getJson()PARK_PATH.getValueJson()
{
 
"name": "PARK_PATH",
 
"type": "Geometry",
 
"item": {
   
"name": "PARK_PATH",
   
"labels": [
      {
       
"text": "Park Path"
      }
    ],
   
"contentType": "Geometry",
   
"start": 6,
   
"length": 1
  },
 
"occurrences": {
   
"record": 1,
   
"item": 1
  },
 
"value": {
   
"metadata": {
     
"filename": "noel-dorwart-trail.geojson",
     
"mime": "application/geo+json"
    },
   
"content": {
     
"url": "http://localhost:55800/vf/1/noel-dorwart-trail.geojson"
    }
  }
}
{
 
"metadata": {
   
"filename": "noel-dorwart-trail.geojson",
   
"mime": "application/geo+json"
  },
 
"content": {
   
"url": "http://localhost:55800/vf/1/noel-dorwart-trail.geojson"
  }
}
To modify a Geometry's value from JSON using Geometry.setValueFromJson, CSPro can parse binary data as a data URL or can read a file from the disk. An exception occurs if the value is not defined properly or if the data is not valid GeoJson. For more information, see details on how to specify binary data for JSON deserialization.
In addition to the deserialization approaches common for all binary data, Geometry data can also be specified directly as GeoJson using the "json" property. For example:
string geojson = "{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[-76.352918,40.05415]},\"properties\":{\"name\":\"Noel Dorwart Park\"}}";

Geometry park_location;
park_location.
setValueFromJson(maketext("{ \"content\": { \"json\": %s } }", geojson));
See also: JSON Representation of Symbols Overview, CSPro ⇄ JSON Conversions: Binary Data