Skip to content

OSL ‐ Json Handling

Mistium edited this page Jun 19, 2024 · 18 revisions

About

Json is a major part of large data storage in osl. It allows for much more complex data structures over basic variables

OSL has array documentation here: Array Documentation

Defining Json objects and arrays

object = {"key":"data","key2":"data2"}
array = ["data","data2","data3"]

You can store arrays in arrays 😱

array = [["data","data2"],"data3","data4"]

Official JSON docs: Json Documentation

Setting json array items

array.[itemid] = "data"

Setting json keys

object.key = "data"
object."key" = "data"
object.["key"] = "data"

Examples

array = ["data",["data2","data3"]]

temp = array.[2]
temp.[2] = "data4"
array.[2] = temp

If you run the above code, array is now equal to ["data",["data2","data4"]]

ARRAY INDEXES START AT 1!!

item_of_array = array.[index]
^ Newer replacement command ^

item_of_array = array.item(index)
^ Old Command (Not in wide use anymore) ^
key_of_object = object.["key"]
key_of_object = object."key"
key of object = object.key

originOS Wiki

Wiki Views:
:views

OSL | RSH | ICN

Clone this wiki locally