Repository navigation
Encoding and Decoding JSON
Encoding and decoding a JSON object or string uses the VaRest JSON nodes. Store each object you construct. If a later node reads a construct pin directly, you can end up with a new object and lose the one you filled in.
Start with Construct Json Object. You can also build a value first and nest it:
- Construct Json String Value
- Construct Json Number Value
- Construct Json Bool Value
- Construct Json Array Value
- Construct Json Object Value
The value nodes are pure. Use the result in the same chain, or keep it, or each read makes a new value.
Write fields with Set Field, which takes the object, a field name, and a JSON value. For plain values there are direct nodes: Set String Field, Set Number Field, Set Number Field Double, Set Integer Field, Set Int64 Field, Set Bool Field, Set Object Field, and Set Array Field.
Encode Json turns the object into a formatted string. Encode Json to Single String keeps it on one line.
Construct Json Object, then Decode Json. It takes the object and a JSON string, and returns whether the string was valid JSON.
Read fields with Get Field, or with Get String Field, Get Number Field, Get Integer Field, Get Int64 Field, Get Bool Field, Get Object Field, and Get Array Field. Has Field checks that a name exists. Get Field Names lists the names on the object.
For a response body, use Get Response Content As String and pass that string to Decode Json.