# Working with URLs and Base64

When working with external systems nearly all communications will be done through data of [The Text Variable Data Type](../../variable-data-types/the-text-variable-data-type). For example, when sending an App Object thrugh an [HTTP Request Data Operation](../../data-operations/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 Encoding

JSON is a very common for encoding complex data such as [Lists](../../variable-data-types/the-list-data-type) or App Objects to Text. The [TO\_JSON](../../airscript-expressions/datatype-functions/to_json), and [FROM\_JSON](../../airscript-expressions/datatype-functions/from_json) functions can encode/decode all types to and from JSON. For example, if we were to encode this library listing to JSON:

```javascript
TO_JSON([  
  {  
    name: "John Doe",  
    number: 5  
  },  
  {  
    name: "Jane Doe",  
    number: 6  
  }  
])
```

the result would be the following JSON

```json
[  
  {  
    "name": "John Doe",  
    "number": 5  
  },  
  {  
    "name": "Jane Doe",  
    "number": 6  
  }  
]
```

Also note, that JSON is valid Airscript. This makes it very convenient to copy paste JSON into an Expression Editor.

Values of the [Datetime](../../variable-data-types/the-datetime-variable-data-type), [Date](../../variable-data-types/the-date-variable-data-type), and [Time](../../variable-data-types/the-time-variable-data-type) 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](https://docs.airkit.ai/?q=working-with-date,-time-and-datetime-in-airscript) for information about common encodings of Dates and Datetimes.

Values of the [Currency](../../variable-data-types/the-currency-variable-data-type) type are likely to have different encodings with different external systems. See [Working with Numbers and Currency in Airscript](https://github.com/airkit/airkit-docs/blob/master/docs/v18-2/working-with-numbers-and-currency.md) for information on how to encode a Currency in Text.

### URL Encoding

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](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](https://www.google.com/search?q=low%20code). Use the [URL\_ENCODE](../../airscript-expressions/encoding-functions/url_encode) and [URL\_DECODE](../../airscript-expressions/encoding-functions/url_decode) functions to encode and decode text for use in URLs.

```javascript
"https://www.google.com/search?q={{URL_ENCODE(example_search_query)}}"
```

Note, however, that when using an [HTTP Request Data Operation](../../data-operations/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](../../airscript-expressions/encoding-functions/url_encode) function should not be used.

### Base64 Encoding

While JSON is a way to encode more complex data types such as [Lists](../../variable-data-types/the-list-data-type) and Objects into [Text](../../variable-data-types/the-text-variable-data-type), 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](../../variable-data-types/the-text-variable-data-type) may need to be encoded or decoded when working with an external system. The [BASE64\_ENCODE](../../airscript-expressions/encoding-functions/base64_encode) and [BASE64\_DECODE](../../airscript-expressions/encoding-functions/base64_decode) functions can be used in these cases.
