When working with external systems nearly all communications will be done through data of The Text Variable Data Type. For example, when sending an App Object thrugh an HTTP Request Data Operation the app Object will typically be encoded as JSON. Airkit provides functions to help encode data as Text for different common use cases.
JSON is a very common for encoding complex data such as Lists or App Objects to Text. The TO_JSON, and FROM_JSON functions can encode/decode all types to and from JSON. For example, if we were to encode this library listing to JSON:
name: "John Doe",
name: "Jane Doe",
the result would be the following JSON
"name": "John Doe",
"name": "Jane Doe",
Also note, that JSON is valid Airscript. This makes it very convenient to copy paste JSON into an Expression Editor.
Values of the Datetime, Date, and Time types encode to JSON as objects, however, external systems will often have unique encodings for these types. See Working with Date, Time & DateTime in Airscript for information about common encodings of Dates and Datetimes.
Values of the Currency type are likely to have different encodings with different external systems. See Working with Numbers and Currency in Airscript for information on how to encode a Currency in Text.
When developing a web application it is often useful to embed data in the url of a web page. Search engines will often encode the query in a URL Query Parameter, for example a Google search for airkit has q=airkit at the end of the url: https://www.google.com/search?q=airkit. However, notice that search for the term low code needs special treatment because of the space: https://www.google.com/search?q=low%20code. Use the URL_ENCODE and URL_DECODE functions to encode and decode text for use in URLs.
Note, however, that when using an HTTP Request Data Operation query parameters can be entered separately from the URL, in such a case the parameters will be automatically encoded so the URL_ENCODE function should not be used.
While JSON is a way to encode more complex data types such as Lists and Objects into Text, more complex data such as images or video are commonly encoded using Base64. While Airscript cannot directly access the internal data of images or videos, there are scenarios where Text may need to be encoded or decoded when working with an external system. The BASE64_ENCODE and BASE64_DECODE functions can be used in these cases.