json v1.0.3 JSON.Parser.Charlist.Number View Source

Implements a JSON Number Parser for Charlist 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.Charlist.Number.parse ''
{:error, :unexpected_end_of_buffer}

iex> JSON.Parser.Charlist.Number.parse 'face0ff'
{:error, {:unexpected_token, 'face0ff'}}

iex> JSON.Parser.Charlist.Number.parse '-hello'
{:error, {:unexpected_token, 'hello'}}

iex> JSON.Parser.Charlist.Number.parse '129245'
{:ok, 129245, ''}

iex> JSON.Parser.Charlist.Number.parse '7.something'
{:ok, 7, '.something'}

iex> JSON.Parser.Charlist.Number.parse '7.4566something'
{:ok, 7.4566, 'something'}

iex> JSON.Parser.Charlist.Number.parse '-88.22suffix'
{:ok, -88.22, 'suffix'}

iex> JSON.Parser.Charlist.Number.parse '-12e4and then some'
{:ok, -1.2e+5, 'and then some'}

iex> JSON.Parser.Charlist.Number.parse '7842490016E-12-and more'
{:ok, 7.842490016e-3, '-and more'}