Giter Site home page Giter Site logo

jsonex's Introduction

JSON for Elixir

Build Status

Encoding

JSON.encode [ok: true] #=> "{\"ok\":true}"

Decoding

JSON.decode "{\"ok\":true}" #=> [{"ok",true}]

Custom encoder/decoders

defmodule MyJSON do
  use JSON

  def pre_encoder(:undefined), do: :null
  def pre_encoder(value), 	   do: super(value)

  def post_decoder(null),  do: :undefined
  def post_decoder(value), do: super(value)
end

jsonex's People

Contributors

onkel-dirtus avatar opakalex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

vanessaklee

jsonex's Issues

json from nested list

When I have list with nested list elements
[query: [filtered: [query: [term: ["name.first": "shay"]], filter: [or: [filters: [[range: [postDate: [from: "2010-03-01", to: "2010-04-01"]]],[prefix: ["name.second": "ba"]]], _cache: true]]]]]

Then I get
{"query":{"filtered":{"filter":{"or":{"_cache":true,"filters":[{"range":{"postDate":{"from":"2010-03-01","to":"2010-04-01"}}},{"prefix":{"name.second":"ba"}}]}},"query":{"term":{"name.first":"shay"}}}}}

example from https://github.com/datahogs/tirexs

Travis Build Failed when use jsonex as dependency in mixx project

See more in this https://travis-ci.org/datahogs/tirexs

215* Getting jsx [git: "[email protected]:talentdeficit/jsx.git"]
216Cloning into '/home/travis/build/datahogs/tirexs/deps/jsx'...
217Host key verification failed.
218fatal: Could not read from remote repository.
219
220Please make sure you have the correct access rights
221and the repository exists.
222** (Mix) command `git clone --no-checkout "[email protected]:talentdeficit/jsx.git"    "/home/travis/build/datahogs/tirexs/deps/jsx"` failed

Incompatible with Elixir 0.14

You're using the old sigil syntax, %r for regular expressions, instead of the current ~r, which gives a compilation error:

> mix deps.compile jsonex
* Compiling jsonex

== Compilation error on file lib/json/decoder.ex ==
** (SyntaxError) lib/json/decoder.ex:20: invalid token: \d{4}-\d{2}-\d{2}$/
    (elixir) lib/kernel/parallel_compiler.ex:91: anonymous fn/3 in Kernel.ParallelCompiler.spawn_compilers/8

If I fix the regexes, then I get this error

> mix deps.compile jsonex
* Compiling jsonex
Compiled lib/json/encoder.ex
Compiled lib/json/decoder.ex
lib/json.ex:12: warning: Kernel.defexception/2 is deprecated, use defexception/1 instead
lib/json.ex:13: warning: Kernel.defexception/2 is deprecated, use defexception/1 instead

== Compilation error on file lib/json.ex ==
** (CompileError) lib/json.ex:12: cannot invoke function opts/1 inside match
    (stdlib) lists.erl:1352: :lists.mapfoldl/3
    (stdlib) lists.erl:1353: :lists.mapfoldl/3
    (elixir) src/elixir_clauses.erl:26: :elixir_clauses.match/3
    (elixir) src/elixir_clauses.erl:35: :elixir_clauses.clause/7
    (elixir) src/elixir_def.erl:182: :elixir_def.translate_clause/7
    (elixir) src/elixir_def.erl:171: :elixir_def.translate_definition/8
    (elixir) src/elixir_def.erl:89: :elixir_def.store_definition/9
    (elixir) src/elixir.erl:156: :elixir.erl_eval/2

README typo

null โ€“> :null in post_decoder function

Broken compile on Travis

When I compile jsonex in my project on Travis I got this error:
jsonex/lib/json.ex:12: function function/2 undefined

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.