Page History
| Wiki Markup |
|---|
Although you can serialize your XPRIM_JsonObject or XPRIM_JsonArray into a JSON string, if all you want to do is construct a JSON string, or construct a JSON body for XPRIM_HttpRequest, you should use XPRIM_JsonWriter, as it is designed to efficiently construct JSON strings. XPRIM_JsonWriter has a much better performance and lower memory footprint, especially for big JSON data.
As an example, let's use XPRIM_JsonWriter to construct the following JSON string:
\{
"name": \{
"given": "John",
"surname": "Smith"
\},
"age": 45,
"contactNo":
\[
\{ area: "02", no: "9378 2867", type: "landline" \},
\{ no: "0468 732 371", type: "mobile" \}
\]
\}
Start by creating an XPRIM_JsonWriter object.
Define_Com Class(#XPRIM_JsonWriter) Name(#Writer)
Specify the output mode of the writer. Three output modes are supported: |
- String
- File
- HTTP request body
...