• <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
    • Text Templates
    • Templated Reporting System
      • Templated Reports
      • Report.save Function
      • Report.view Function
      • JSON Representation
    • 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: Report Object

The text of a CSPro templated report (Report) is represented as a JSON string that is serialized according to the JSON serialization rules for string values. The value is a string while the report is being created, and null otherwise.
When converting a JSON value to a Report, an exception occurs if the value is not a valid string, or if the templated report is not in the process of creation.
The JSON for a Report named INT_INVEST_REPORT retrieved using Report.getJson may look similar to:
{
 
"name": "INT_INVEST_REPORT",
 
"type": "Report",
 
"template": {
   
"name": "international-investment.html",
   
"encoding": "HTML",
   
"path": "C:/surveys/reports/international-investment.html",
   
"extension": "html",
   
"contentType": "text/html"
  },
 
"value": null
}
The Report's value will generally be null, but if converting the object to JSON while the Report's text template is being generated, the value will reflect the text processed up to the point of the function call. For example, given the following templated report, written in Markdown:
<? $.setValueFromJson("\"Pre-title text!\""); ?>

# Report Title

~~$.getValueJson()~~

Some **important** content!

~~$.getValueJson()~~
The evaluated report will appear with the values represented as JSON strings encoded for Markdown:
Pre-title text!

# Report Title

"Pre\-title text\!\\n\\n\# Report Title\\n\\n"

Some
**important** content!

"Pre\-title text\!\\n\\n\# Report Title\\n\\n\\"Pre\\\\\-title text\\\\\!\\\\\\\\n\\\\\\\\n\\\\\# Report Title\\\\\\\\n\\\\\\\\n\\"\\n\\nSome \*\*important\*\* content\!\\n\\n"
See also: JSON Representation of Symbols Overview