• <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
      • HashMap Object
      • Image Object
        • Image Statement
        • Image.load Function
        • Image.save Function
        • Image.width Function
        • Image.height Function
        • Image.getExif Function
        • EXIF Tags
        • Image.resample Function
        • Image.createQRCode Function
        • Image.takePhoto Function
        • Image.captureSignature Function
        • Image.view Function
        • Image.clear Function
        • JSON Representation
      • 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: Image Object

A CSPro Image 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 Image.getJson on an Image 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 an Image dictionary item, ROOF_IMAGE, to JSON using the default way of representing the binary data as a localhost URL, may look like:
ROOF_IMAGE.getJson()ROOF_IMAGE.getValueJson()
{
 
"name": "ROOF_IMAGE",
 
"type": "Image",
 
"item": {
   
"name": "ROOF_IMAGE",
   
"labels": [
      {
       
"text": "Roof Image"
      }
    ],
   
"contentType": "Image",
   
"start": 4,
   
"length": 1
  },
 
"occurrences": {
   
"record": 1,
   
"item": 1
  },
 
"value": {
   
"metadata": {
     
"filename": "CTB_1758807115.jpg",
     
"mime": "image/jpeg"
    },
   
"content": {
     
"url": "http://localhost:50505/vf/3/CTB_1758807115.jpg"
    }
  }
}
{
 
"metadata": {
   
"filename": "CTB_1758807115.jpg",
   
"mime": "image/jpeg"
  },
 
"content": {
   
"url": "http://localhost:50505/vf/3/CTB_1758807115.jpg"
  }
}
To modify an Image's value from JSON using Image.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 a valid image that CSPro can process. For more information, see details on how to specify binary data for JSON deserialization.
See also: JSON Representation of Symbols Overview, CSPro ⇄ JSON Conversions: Binary Data