Helpers for massaging raw JSON (as decoded from an external API) into the shapes our schemas expect.
Summary
Functions
Fetches key from map, accepting either the atom key or its string form.
Recursively rewrites a map's camelCase keys (atom or string) into
snake_case string keys, descending into nested maps and lists.
Functions
Fetches key from map, accepting either the atom key or its string form.
The HTTP layer decodes JSON to atom keys, but a body we re-decoded locally has string keys — so try the atom first, then fall back to the string.
Recursively rewrites a map's camelCase keys (atom or string) into
snake_case string keys, descending into nested maps and lists.
Bridges the Gamma API's camelCase payloads to our snake_case schema fields.
iex> Polymarket.JsonUtil.snake_case_keys(%{conditionId: "0x1", feeSchedule: %{rebateRate: 0.2}})
%{"condition_id" => "0x1", "fee_schedule" => %{"rebate_rate" => 0.2}}