• <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
      • List Object
      • Map Object
      • Path
      • Pff Object
      • StringWriter Object
        • StringWriter Statement
        • StringWriter.clear Function
        • StringWriter.toString Function
        • StringWriter.write Function
        • StringWriter.writeEncoded Function
        • StringWriter.writeEncodedLine Function
        • StringWriter.writeLine Function
        • JSON Representation
      • 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: StringWriter Object

The text of a CSPro StringWriter is represented as a JSON string that is serialized according to the JSON serialization rules for string values.
When converting a JSON value to a StringWriter, an exception occurs if the value is not a valid string.
The JSON for a StringWriter named ea_table_html that uses HTML encoding, retrieved using StringWriter.getJson, may look similar to:
{
 
"name": "ea_table_html",
 
"type": "StringWriter",
 
"encoding": "HTML",
 
"value": ""
}
The StringWriter.getValueJson function returns the same value as StringWriter.toString, encoded as a JSON string. For example:
StringWriter ea_table_html(HTML);

ea_table_html.
setValueFromJson("\"<table><tr><td>\"");
ea_table_html.
writeEncoded("Blind <Hoon> Time");
ea_table_html.
write("</td></tr></table>");

// <table><tr><td>Blind &lt;Hoon&gt; Time</td></tr></table>
errmsg("%s", ea_table_html.toString());

// "<table><tr><td>Blind &lt;Hoon&gt; Time</td></tr></table>"
errmsg("%s", ea_table_html.getValueJson());
See also: JSON Representation of Symbols Overview