Coder Social home page Coder Social logo

exjsx's Introduction

i have no good ideas for this yet

exjsx's People

Contributors

d0rc avatar edgurgel avatar izaakschroeder avatar lowks avatar milmazz avatar parroty avatar talentdeficit avatar yrashk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

exjsx's Issues

JSEX.encode wrong documentation?

On README.md:

iex> JSEX.encode [library: "jsx", awesome: true]
"{\"library\":\"jsx\",\"awesome\":true}"
iex> JSEX.encode ["a","list","of","words"]
"[\"a\",\"list\",\"of\",\"words\"]"

on code:

 def encode(term, opts // []) do
{:ok, encode!(term, opts)}
  rescue
    ArgumentError -> {:error, :badarg}
  end

When I use:

iex> JSEX.encode(a: "b", c: "d")
{:ok,"{\"a\":\"b\",\"c\":\"d\"}"}

Change name

Can we rename this project to something less graphic?

Maps support

I was just wondering what the plan for Maps support is.

Streaming / Incomplete Support

The documentation mentions the upcoming streaming support. Is this still on the list? Or should one use jsx directly from Elixir for now?

JSEX.prettify! behaviour changed?

Is this new behaviour expected?

Before:
ref: 65aa6ae

iex> JSEX.encode!([a: "b"]) |> JSEX.prettify!
"{\n  \"a\": \"b\"\n}"

Now:
tag: v1.0.1

iex> JSEX.encode!([a: "b"]) |> JSEX.prettify!
"{\"a\": \"b\"}"

encoding record fails with: (MatchError) no match of right hand side value

it seems that tests are currently failing that try to encode records:

  1) test encode a list of simple records (JSEX.Tests.Records)
     ** (MatchError) no match of right hand side value: "Walder Frey"
     stacktrace:
       lib/jsex.ex:140: JSEX.Encoder.Tuple."-json/1-fun-0-"/3
       /private/tmp/elixir-ui1f/lib/elixir/lib/enum.ex:618: Enum."-map/2-lc$^0/1-0-"/2
       lib/jsex.ex:136: JSEX.Encoder.Tuple.json/1
...

Weird encode issue

iex> JSEX.encode([{"userid" , "userinfo"}])
{:error,:badarg}
iex> :jsx.encode([{"userid" , "userinfo"}])
"{\"userid\":\"userinfo\"}"

Is this expected?

README.md is_json and is_term links

They dont have the '?' on index links

 exports

    decode and decode!
    encode and encode!
    format and format!
    minify and minify!
    prettify and prettify!
    is_json
    is_term

Question about legacy support

Is it important for this project to support legacy version of elixir? I'd like to update to discontinue support of < 1.2 and make some updates to get rid of compiler warnings when using this a downstream dependency with 1.4. Thoughts?

image

Tuple/Record encoding issue

The following examples should encode the same (in my opnion):

iex> defrecord SimpleRecord, name: nil, rank: nil
{:module,SimpleRecord,<<70,79,82,49,0,0,15,148,66,69,65,77,65,116,111,109,0,0,0,246,0,0,0,26,19,69,108,105,120,105,114,46,83,105,109,112,108,101,82,101,99,111,114,100,8,95,95,105,110,102,...>>,nil}
iex> JSEX.encode([a: [[name: "Walder Frey", rank: "Lord"]]])
{:ok,"{\"a\":[{\"name\":\"Walder Frey\",\"rank\":\"Lord\"}]}"}
iex> JSEX.encode([a: [SimpleRecord.new(name: "Walder Frey", rank: "Lord")]])
{:error,:badarg}

But they don't.

JSEX.is_json? is correct?

JSEX.is_json? is defined as follow:

https://github.com/talentdeficit/jsex/blob/develop/lib/jsex.ex#L60

 def is_json?(json, opts \\ []) do
    case :jsx.is_json(json, opts) do
      { :incomplete, _ } -> false
      result -> result
    end
  rescue
    _ -> false
  end

But on jsx:is_json the type spec says:

https://github.com/talentdeficit/jsx/blob/v2.0.1/src/jsx.erl#L85-L86

-spec is_json(Source::any()) -> true | false.
-spec is_json(Source::any(), Config::jsx_verify:config()) -> true | false.

jsx:is_json returns true or false, but on JSEX it checks for { :incomplete, _}

Is it correct? Am I missing something?

encode HashDict?

Would be cool to have on jsex enconding of a HashDict?

I can work on it if you think that's cool.

key in map using atoms as keys

JSEX.encode! %{ nil: nil } produces the JSON string, {"null":null}.

It should probably produce {"nil":null} instead, so that when it is
converted back to Elixir by JSEX.decode with option {:labels, :atom}
it does not become %{null: nil} ... which is what happens now.

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.