JSON with the rules of Python json: dumps/2 for the tojson filter, and decode!/1 to keep the key order of objects.
dumps/2 gives the same text as Python json.dumps, with its options ensure_ascii, indent, separators and sort_keys. Floats use the Python repr(), so 1.0 stays 1.0.
Summary
Functions
Decodes JSON text into template values. Objects become Otera.Dict structs with the key order of the text, like json.loads in Python.
Encodes value like Python json.dumps.
Functions
Decodes JSON text into template values. Objects become Otera.Dict structs with the key order of the text, like json.loads in Python.
Use it to give a template the tool definitions or messages of a JSON request, so that tojson prints their keys in the same order as transformers.
iex> Otera.JSON.decode!(~s({"b": 1, "a": 2}))
%Otera.Dict{pairs: [{"b", 1}, {"a", 2}]}
Encodes value like Python json.dumps.
Options: :ensure_ascii (default true), :indent (an integer or a string), :separators (a {item, key} tuple) and :sort_keys (default false).