talentdeficit / exjsx Goto Github PK
View Code? Open in Web Editor NEWjson for elixir
License: Other
json for elixir
License: Other
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\"}"}
Can we rename this project to something less graphic?
please take a look at this and let me know if you have any thoughts if you're interested in jsex's incompletes support
I was just wondering what the plan for Maps support is.
The documentation mentions the upcoming streaming support. Is this still on the list? Or should one use jsx directly from Elixir for now?
Hello is there any simple trick to convert an IEE754 formatted hex number to dec ?
http://www6.uniovi.es/~antonio/uned/ieee754/IEEE-754hex32.html
for example C0240000 is converted to -2.5625
Regards
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\"}"
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
...
iex> JSEX.encode([{"userid" , "userinfo"}])
{:error,:badarg}
iex> :jsx.encode([{"userid" , "userinfo"}])
"{\"userid\":\"userinfo\"}"
Is this expected?
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
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.
The module should probably be renamed. Thoughts?
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?
I was recently working on a project that required a conversion from a list of tuples from decoded json to a map. Would you be interested in this type of new feature that would result in a map being decoded from json rather than a list of tuples?
Here's a gist to the code that I could add in a pull-request: https://gist.github.com/rcdilorenzo/3ae32c5e5ccc4c7ba078
Do you plan to publish the current version on hex.pm, too? I would really appreciate it! ๐
Would be cool to have on jsex enconding of a HashDict?
I can work on it if you think that's cool.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.