mumu 0.10.0

Lava Mumu is a language for those in the now and that know
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
  "id": "fn-json-encode",
  "dataComponent": "json",
  "heading": {
    "title": "encode",
    "badges": ["JSON", "PARTIAL"]
  },
  "synopsis": "Converts a Lava Value into a JSON string. The first argument is a KeyedArray of options (required), the second is the data.",
  "codeBlocks": [
    "extend(\"json\")\n\n# 1) Basic usage => encode a keyed array:\njs = json:encode([ pretty:true ], [ name:\"Alice\", age:30 ])\nsput(js)\n# => prints something like:\n# {\n#   \"name\": \"Alice\",\n#   \"age\": 30\n# }\n\n# 2) Using indent => place a custom indentation\njs2 = json:encode([ pretty:true, indent:\"  \" ], [1,2,3])\nsput(js2)\n# => \"[\\n  1,\\n  2,\\n  3\\n]\"\n\n# 3) Partial usage => supply only the 'options' first\nmyEnc = json:encode([ pretty:false ])\nres = myEnc( [1,2,3] )\nsput(res)\n# => \"[1,2,3]\"\n\n# 4) Underscore placeholders => skip the first or second param\nencData = json:encode(_, [ true, false ])\nres2 = encData([ pretty:true ])\nsput(res2)\n# => \"[\\n  true,\\n  false\\n]\"\n"
  ],
  "notes": [
    "Usage: `json:encode( optionsKeyedArray, dataValue ) => SingleString(jsonText)`.\n- The first argument is a KeyedArray (or `_` placeholder) of options. It must at least exist, even if empty: `[ ]`.\n- The second argument is the Lava data to encode (int, float, array, keyed array, etc.).",
    "Supported options:\n- `pretty`: bool => if true, uses pretty-printed JSON.\n- `indent`: SingleString => if `pretty=true`, replaces the default 4-space indentation with a custom string (e.g. \"\\t\" or \"  \").",
    "If you partially apply, you can pass the options now and the data later, or placeholders for either argument.",
    "Any function or InkTransform encountered in the data is turned into `null` (or bridging default). Mixed numeric arrays unify if possible (int => float, etc.)."
  ]
}