BoundedAuthorityReportAdapter. Conformance. Tag
(Bounded Authority Report Adapter v0.5.0)
Copy Markdown
View Source
TEST-ONLY translator: the vector's typed-JSON array form to BAP's tagged
Json.value() tuple form (design §1.6 A).
The vector stores typed values as JSON arrays ["typename", value] (e.g.
["object", {...}], ["string", "us-east"]). BAP's RequestDigest.typed/1
requires the tagged tuple form ({:object, members}, {:string, v}, ...).
A raw map or a JSON-decoded list is rejected ({:error, :invalid}).
No type guard on the object/array arms
:json.decode decodes JSON objects to Elixir %{}{} maps, and Enum.map
over a map yields {key, value} tuples — so the object arm's fn {k,v}
body is happy with a map. A when is_list(members) guard would BREAK on the
real (map-shaped) data (verified first-hand during the design).
Summary
Functions
Translates a ["type", value] JSON-array form into a BAP tagged tuple.
Translates a RAW :json.decode value (no type tags — the form the
local-loopback profile corpus stores its cast_arguments in) into the
tagged tuple form. The mirror of from_json/1 for corpora that carry plain
JSON instead of the typed-array encoding.
Functions
Translates a ["type", value] JSON-array form into a BAP tagged tuple.
iex> from_json(["string", "us-east"])
{:string, "us-east"}
iex> from_json(["integer", 10])
{:integer, 10}
iex> from_json(["null"])
:null
Translates a RAW :json.decode value (no type tags — the form the
local-loopback profile corpus stores its cast_arguments in) into the
tagged tuple form. The mirror of from_json/1 for corpora that carry plain
JSON instead of the typed-array encoding.
iex> from_raw(%{"record_id" => "record-1"})
{:object, [{"record_id", {:string, "record-1"}}]}
iex> from_raw(5)
{:integer, 5}