Xbasic
json_from_yaml Function
Syntax
C result json = json_from_yaml(yamlText as C)
Arguments
- yamlTextCharacter
A string containing YAML to convert to JSON.
Description
Converts a string containing YAML to JSON.
Discussion
YAML is a markup language that is sometimes used in place of JSON. This function converts YAML to JSON. This function is just a wrapper around the Extension::JSON class.
Example
yaml = <<%str% fname: john lname: public children: - name: callie hobbies: - minecraft - leggo - name: griffin hobbies: - ballet address: street: 12 and main city: Squares Ville State: KY %str% json_from_yaml(yaml) = { "fname": "john", "lname": "public", "children" : [ {"name": "callie","hobbies": ["minecraft","leggo"]}, {"name": "griffin","hobbies": ["ballet"]} ], "address": { "street": "12 and main", "city": "Squares Ville", "State": "KY" } }
See Also