json v1.0.3 JSON.Parser.Bitstring.Number View Source
Implements a JSON Numeber Parser for Bitstring values
Link to this section Summary
Functions
parses a valid JSON numerical value, returns its elixir numerical representation
Link to this section Functions
parses a valid JSON numerical value, returns its elixir numerical representation
Examples
iex> JSON.Parser.Bitstring.Number.parse ""
{:error, :unexpected_end_of_buffer}
iex> JSON.Parser.Bitstring.Number.parse "face0ff"
{:error, {:unexpected_token, "face0ff"}}
iex> JSON.Parser.Bitstring.Number.parse "-hello"
{:error, {:unexpected_token, "hello"}}
iex> JSON.Parser.Bitstring.Number.parse "129245"
{:ok, 129245, ""}
iex> JSON.Parser.Bitstring.Number.parse "7.something"
{:ok, 7, ".something"}
iex> JSON.Parser.Bitstring.Number.parse "7.4566something"
{:ok, 7.4566, "something"}
iex> JSON.Parser.Bitstring.Number.parse "-88.22suffix"
{:ok, -88.22, "suffix"}
iex> JSON.Parser.Bitstring.Number.parse "-12e4and then some"
{:ok, -1.2e+5, "and then some"}
iex> JSON.Parser.Bitstring.Number.parse "7842490016E-12-and more"
{:ok, 7.842490016e-3, "-and more"}