JSON Helper

From Onix OS Wiki
Jump to: navigation, search

The jsonp()function is used to parse the JSON. It is extremely simple to use. Returns the result as a hash.


jsonp(filename or string)

JSON parse operations are very easy. Just specify a string or file. If there is no file in the string, it will automatically renounce the read operation and read it as a string instead.


def json = (jsonp("test.json"))

# => { hello: Hello World, title: Hello Example,  hello2: [{test: Test}, {test: Test}]}

In the example, we wanted to read the JSON file and return the results. You can make your own experiments.