add 'to_json' and 'from_json' to builtin documentation

This commit is contained in:
Daniel Kang 2019-01-26 06:40:13 -08:00
parent 5e2187d94a
commit bbc76a0228

View file

@ -63,6 +63,26 @@ v := [1]
v = append(v, 2, 3) // v == [1, 2, 3]
```
## to_json
Returns the JSON encoding of an object.
```golang
print(to_json([1, 2, 3])) // [1, 2, 3]
print(to_json(4)) // 4
print(to_json("five")) // "five"
```
## from_json
Parses the JSON-encoded data and returns an object.
```golang
arr := from_json(`[1, 2, 3]`)
four := from_json(`4`)
five := from_json(`"five"`)
```
## string
Tries to convert an object to string object. See [this](https://github.com/d5/tengo/wiki/Variable-Types) for more details on type conversion.