Data
libraryCollects the result data of a run in one table. What you put in with `Data.set` is encoded as JSON when the run ends and stored with the run log, where the server shows it as the data of that run. The table is empty (`{}`) when nothing was set. Because the table is encoded like `Json.encode`, it may only hold strings, numbers, booleans and nested tables; a value JSON cannot hold makes the encoding fail.
- Kind Library, a global in every script
- Category APIs & Data
- Functions 4
Functions
Data.set(luaTable: table)→selfData.set(key: any, value: any)→self Sets run data. With one argument, the given table replaces all data collected so far; the table is used as it is, not copied, so later changes to it are part of the data. With two arguments, one key is set; setting a key to `nil` removes it. With a single argument that is not a table the call throws.
Parameters
-
keyany - Key, normally a string
-
valueany - Value to store: string, number, boolean or table
-
luaTabletable - Table that becomes the run data, replacing the current one
Returns
Example runs in CI
Data.set("status", "ok")Data.set("count", 3)print(Data.json())clear()
Section titled “clear()”Data.clear()→self Removes all run data collected so far.
Returns
Data.get()→table Returns the data table itself (not a copy), so changes to it change the run data.
Returns
json()
Section titled “json()”Data.json()→string Returns the run data encoded as pretty-printed JSON, the same text that is stored when the run ends. Throws for values JSON cannot hold, as `Json.encode` does.
Returns