Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get value from json obj? #182

Closed
dcy opened this issue Jul 20, 2014 · 1 comment
Closed

How to get value from json obj? #182

dcy opened this issue Jul 20, 2014 · 1 comment

Comments

@dcy
Copy link
Contributor

dcy commented Jul 20, 2014

The xxx_controller :
TestJson = jsx:encode([{<<"library">>,<<"jsx">>},{<<"awesome">>,true}]),

The template:

{{ test_json.library }}


the console's error:
error function_clause [{erlydtl_runtime,find_value,[library,<<"{"library":"jsx","awesome":true}">>],[{file,"src/erlydtl_runtime.erl"},{line,52}]}

@seriyps
Copy link
Member

seriyps commented Jul 20, 2014

If your code looks like

TestJson = jsx:encode([{<<"library">>,<<"jsx">>},{<<"awesome">>,true}]),
my_template:render([{test_json, TestJson}]).

change it to

TestJson = [{<<"library">>,<<"jsx">>},{<<"awesome">>,true}],
my_template:render([{test_json, TestJson}]).

Because erlydtl don't parse JSON, but operates under erlang k-v structures.

Also, please, note, that github issues isn't the place for Q&A, but place for reporting bugs.

@dcy dcy closed this as completed Jul 21, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants