-- Showcase the calog json library: jsonParse a nested JSON document, read its -- fields, then build a Lua table and jsonStringify it back to text. -- Run: bin/calog examples/scripts/libraries/json.lua local text = [[ { "name": "calog", "version": 2, "stable": true, "notes": null, "engines": ["lua", "javascript", "scheme"], "limits": { "maxTasks": 64, "ratio": 1.5 } } ]] local doc = jsonParse(text) calogPrint("name:", doc.name) calogPrint("version:", doc.version) calogPrint("stable:", doc.stable) calogPrint("notes is nil:", doc.notes == nil) calogPrint("first engine:", doc.engines[1]) calogPrint("engine count:", #doc.engines) calogPrint("limits.maxTasks:", doc.limits.maxTasks) calogPrint("limits.ratio:", doc.limits.ratio) local report = {} report.tool = "calog" report.ok = true report.count = doc.engines report.summary = { engines = #doc.engines, maxTasks = doc.limits.maxTasks } calogPrint("stringified:", jsonStringify(report)) calogExit(0)