Skip to content

jerp/elixir-json

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Elixir JSON

Build Status

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

All contributions are welcome.

Installing

Simply add { :json, github: "cblage/elixir-json"} to your project's mix.exs file, in the dependencies list and run mix deps.get json.

Example for a project that already uses Dynamo:

defp deps do
    [ { :cowboy, github: "extend/cowboy" },
      { :dynamo, github: "elixir-lang/dynamo" },
      { :json,   github: "cblage/elixir-json"} ]
end

Usage

  JSON.encode([result: "this will be a elixir result"])
  {:ok, "{\"result\":\"this will be a elixir result\"}"}
  JSON.decode("{\"result\":\"this will be a elixir result\"}")
  {:ok, [result: "this will be a elixir result"]}

Dynamo Filter

Elixir JSON includes a convenient filter for the Dynamo web framework.

If you want to use it, simply add Elixir JSON to your project's dependencies, and add the following line to your router:

filter JSON.Dynamo.Filter

Afterwards, to generate JSON responses, simply use conn.put_private and set the :result_object to whatever you want to be converted to JSON:

  get "/whoami" do
    conn.put_private :result_object, [ name: "Carlos", city: "New York", likes: "Programming" ]
  end

License

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

About

Native JSON library for Elixir

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Elixir 100.0%