json

Native JSON library for Elixir

Latest version: 2.1.0-SNAPSHOT registry icon
Maintenance score
0
Safety score
0
Popularity score
73
Check your open source dependency risks. Get immediate insight about security, stability and licensing risks.
Security
  Vulnerabilities
Version Suggest Low Medium High Critical
2.1.0-SNAPSHOT 0 0 0 0 0
2.0.1-SNAPSHOT 0 0 0 0 0
2.0.0-SNAPSHOT 0 0 0 0 0
1.4.1 0 0 0 0 0
1.4.0 0 0 0 0 0
1.3.0 0 0 0 0 0
1.2.5 0 0 0 0 0
1.2.4 0 0 0 0 0
1.2.3 0 0 0 0 0
1.2.2 0 0 0 0 0
1.2.1 0 0 0 0 0
1.2.0 0 0 0 0 0
1.1.0 0 0 0 0 0
1.0.4-SNAPSHOT 0 0 0 0 0
1.0.3 0 0 0 0 0
1.0.2 0 0 0 0 0
1.0.1 0 0 0 0 0
1.0.0 0 0 0 0 0
0.3.3 0 0 0 0 0
0.3.2 0 0 0 0 0
0.3.0 0 0 0 0 0

Stability
Latest release:

2.1.0-SNAPSHOT - This version may not be safe as it has not been updated for a long time. Find out if your coding project uses this component and get notified of any reported security vulnerabilities with Meterian-X Open Source Security Platform

Licensing

Maintain your licence declarations and avoid unwanted licences to protect your IP the way you intended.

BSD-3-Clause   -   BSD 3-Clause "New" or "Revised" License

Not a wildcard

Not proprietary

OSI Compliant



Build Status Hex.pm Coverage Status Inline docs

This library provides a natively implemented JSON encoder and decoder for Elixir.

You can find the package in hex.pm and the documentation in hexdocs.pm.

All contributions are welcome!

Installing

Simply add {:json, "~> 1.4"} to your project's mix.exs and run mix deps.get.

Usage

Encoding an Elixir type

  @doc "
	JSON encode an Elixir list
  "	
  list = [key: "this will be a value"]
  is_list(list)
  # true
  list[:key]
  # "this will be a value"
  {status, result} = JSON.encode(list)
  # {:ok, "{\"key\":\"this will be a value\"}"}
  String.length(result)
  # 41

Decoding a list from a string that contains JSON

  @doc "
	JSON decode a string into an Elixir list
  "
  json_input = "{\"key\":\"this will be a value\"}"
  {status, list} = JSON.decode(json_input)
	{:ok, %{"key" => "this will be a value"}}
  list[:key]
  # nil
  list["key"]
  # "this will be a value"

At any time, you can turn on verbose logging for this library only. To do so, head to config file of your application and add below lines:

use Mix.Config

config :logger, level: :debug

config :json, log_level: :debug

Note that, changing only :logger level to :info, :warn or :error will silent :json too.

License

The Elixir JSON library is available under the BSD 3-Clause aka "BSD New" license