View Source TermToJson (term_to_json v0.1.0)

Convert Elixir terms to and from JSON strings.

Summary

Functions

Decode a JSON string to an Elixir term.

Encode an Elixir term to a JSON string.

Functions

decode(string)

Decode a JSON string to an Elixir term.

Examples

iex> TermToJson.decode(~s({":major": 1,":minor": 3,":build": null,":__struct__": ":Elixir.Version",":pre": [],":patch": 7}))
%Version{major: 1, minor: 3, patch: 7}

encode(term, opts \\ [])

Encode an Elixir term to a JSON string.

Examples

iex> TermToJson.encode(1)
"1"