TypeSafe.JSON.OrderedObject (TypeSafe AI v0.1.0-alpha.1)

Copy Markdown View Source

A JSON object that encodes its pairs in the order given.

Elixir maps with more than 32 keys do not preserve insertion order, and a Choice question can carry up to 255 options. The API treats criteria as an ordered list of options (the order is what the model sees), so Choice criteria travel as this struct rather than as a map.

JSON.encode!(%TypeSafe.JSON.OrderedObject{pairs: [{"b", 1}, {"a", nil}]})
#=> ~s({"b":1,"a":null})

Keys must be atoms or strings. Values may be anything JSON can encode.

Summary

Functions

Wraps a list of {key, value} pairs.

Types

t()

@type t() :: %TypeSafe.JSON.OrderedObject{pairs: [{atom() | String.t(), term()}]}

Functions

new(pairs)

@spec new([{atom() | String.t(), term()}]) :: t()

Wraps a list of {key, value} pairs.