tonyg / erlang-rfc4627 Goto Github PK
View Code? Open in Web Editor NEWErlang RFC4627 (JSON) codec and JSON-RPC server implementation.
Home Page: http://tonyg.github.com/erlang-rfc4627/
Erlang RFC4627 (JSON) codec and JSON-RPC server implementation.
Home Page: http://tonyg.github.com/erlang-rfc4627/
Hi,
This is not a critical bug, but just a information when I tried to add this as dependency with repository name "erlang-rfc4627" to my rebar.config of my project it raised me the below error.
Pulling "erlang-rfc4627" from {git,"git://github.com/marutha/erlang-rfc4627.git",
"master"}
Initialized empty Git repository in /rfc_test/deps/erlang-rfc4627/.git/
ERROR: Dependency dir /rfc_test/deps/erlang-rfc4627 failed application validation with reason:
{name_mismatch,{"/rfc_test/deps/erlang-rfc4627/ebin/rfc4627_jsonrpc.app",
{expected,"erlang-rfc4627"},
{has,rfc4627_jsonrpc}}}.
ERROR: 'get-deps' failed while processing /rfc_test/: rebar_abort
after changing the value to rfc4627_jsonrpc in rebar config the error disappeared.
I guess either repository name has to be changed or some note on read me would be helpful for new users.
Thanks,
Marutha
I read http://tonyg.github.com/erlang-rfc4627/doc/index.html to try play with code...
make all test-compile
erlc -I include -o ebin -Dnew_inets -Wall +debug_info test/test_jsonrpc_inets.erl test/test_rfc4627.erl
test/test_jsonrpc_inets.erl:50: Warning: call to httpd:start/1 will fail, since it was removed in R14B; use inets:start/2,3
Eshell V5.8.4 (abort with ^G)
1> test_jsonrpc_inets:start_httpd().
** exception error: undefined function httpd:start/1
in function test_jsonrpc_inets:start_httpd/0
I hope you find time to fix this little misunderstanding :)
no-tail-recursive result in memory used up.
7> rfc4627:decode( " {"user":"ๅๅ"}" ).
** exception exit: {ucs,{bad_utf8_character_code}}
in function xmerl_ucs:from_utf8/1 (xmerl_ucs.erl, line 185)
in call from rfc4627:unicode_decode/1 (lib/json/rfc4627.erl, line 323)
in call from rfc4627:decode/1 (lib/json/rfc4627.erl, line 258)
Hi,
It seems that the location of httpd.hrl is determined wrongly at 17.0
[ 54s] Building for OTP release 17.
[ 54s] Using path to INETS httpd.hrl that existed before R14A.
[ 54s] erlc -I include -o ebin -Dinets_pre_r14a -Wall +debug_info src/rfc4627.erl
[ 54s] erlc -I include -o ebin -Dinets_pre_r14a -Wall +debug_info src/rfc4627_jsonrpc_registry.erl
[ 54s] erlc -I include -o ebin -Dinets_pre_r14a -Wall +debug_info src/rfc4627_jsonrpc.erl
[ 54s] erlc -I include -o ebin -Dinets_pre_r14a -Wall +debug_info src/rfc4627_jsonrpc_mochiweb.erl
[ 54s] erlc -I include -o ebin -Dinets_pre_r14a -Wall +debug_info src/rfc4627_jsonrpc_cowboy.erl
[ 54s] erlc -I include -o ebin -Dinets_pre_r14a -Wall +debug_info src/rfc4627_jsonrpc_sup.erl
[ 55s] erlc -I include -o ebin -Dinets_pre_r14a -Wall +debug_info src/rfc4627_jsonrpc_http.erl
[ 55s] erlc -I include -o ebin -Dinets_pre_r14a -Wall +debug_info src/rfc4627_jsonrpc_inets.erl
[ 55s] erlc -I include -o ebin -Dinets_pre_r14a -Wall +debug_info src/rfc4627_jsonrpc_app.erl
[ 55s] src/rfc4627_jsonrpc_inets.erl:95: can't find include lib "inets/src/httpd.hrl"
[ 55s] src/rfc4627_jsonrpc_inets.erl:110: record mod undefined
[ 55s] src/rfc4627_jsonrpc_inets.erl:111: variable 'OldData' is unbound
[ 55s] src/rfc4627_jsonrpc_inets.erl:112: variable 'OldData' is unbound
[ 55s] src/rfc4627_jsonrpc_inets.erl:124: record mod undefined
[ 55s] src/rfc4627_jsonrpc_inets.erl:132: variable 'ConfigDb' is unbound
[ 55s] src/rfc4627_jsonrpc_inets.erl:133: variable 'PathAndQuery' is unbound
[ 55s] src/rfc4627_jsonrpc_inets.erl:141: variable 'InetsHeaders' is unbound
[ 55s] src/rfc4627_jsonrpc_inets.erl:142: variable 'SocketType' is unbound
[ 55s] src/rfc4627_jsonrpc_inets.erl:148: variable 'HttpMethod' is unbound
[ 55s] src/rfc4627_jsonrpc_inets.erl:151: variable 'PeerPort' is unbound
[ 55s] src/rfc4627_jsonrpc_inets.erl:152: variable 'PeerName' is unbound
[ 55s] src/rfc4627_jsonrpc_inets.erl:158: variable 'Body' is unbound
[ 55s] src/rfc4627_jsonrpc_inets.erl:160: variable 'OldData' is unbound
[ 55s] src/rfc4627_jsonrpc_inets.erl:172: variable 'OldData' is unbound
[ 55s] Makefile:36: recipe for target 'ebin/rfc4627_jsonrpc_inets.beam' failed
Hello @tonyg
cannot convert to record from json if record is nested.
eg.
record
-record(inputuser,{t= <<"TL_inputUserContact">>,
user_id=null :: integer(),
access_hash = null :: integer()}).
-record(getfulluser,{
id= #inputuser{}}).
code =
JSONReqa = <<"{\"id\":{\"t\":\"TL_inputUserContact\",\"access_hash\":0,\"user_id\":143444}}">>,
?DEBUG("re quersd ~p",[JSONReqa]),
Object23=erlang:element(2,rfc4627:decode(JSONReqa))
?DEBUG("object = ~p",[Object23]),
?DEBUG("record = ~p",[?RFC4627_TO_RECORD(getfulluser,Object23)]),
output is
mod_contacts:gs().
18:38:04.695 [debug] re quersd <<"{\"id\":{\"t\":\"TL_inputUserContact\",\"access_hash\":0,\"user_id\":143444}}">>
18:38:04.697 [debug] object = {ok,{obj,[{"id",{obj,[{"t",<<"TL_inputUserContact">>},{"access_hash",0},{"user_id",143444}]}}]},[]}
18:38:04.697 [debug] object = {obj,[{"id",{obj,[{"t",<<"TL_inputUserContact">>},{"access_hash",0},{"user_id",143444}]}}]}
18:38:04.697 [debug] record = {getfulluser,{obj,[{"t",<<"TL_inputUserContact">>},{"access_hash",0},{"user_id",143444}]}}
{getfulluser,{obj,[{"t",<<"TL_inputUserContact">>},
{"access_hash",0},
{"user_id",143444}]}}
can @0x6e6562 @olcai @tonyg @paulj @matwey please help i really appreciate your help.
it should decode the inner record as well. any pointers will help.
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.