rvirding / erlog

Prolog interpreter in and for Erlang
Apache License 2.0
370 stars 43 forks source link

JSON data support #40

Closed zkessin closed 10 years ago

zkessin commented 10 years ago

It would be nice if we had a way to support JSON data, If you decode a json with JSX you get a data structure like this [{<<"test">>, 12345}], the problem is that if you try to pass that to prolog it thinks that the first element of the tuple is callable. When I ran this test https://gist.github.com/zkessin/52c96f8d5e6285497e8f I get this error:

json_test: json_test (module 'json_test')...*failed*
in function json_test:'-json_test/0-fun-0-'/1 (test/json_test.erl, line 10)
**error:{assertMatch_failed,[{module,json_test},
                     {line,10},
                     {expression,"erlog : prove ( ERLOG_STATE , { length , Data , { 'Len' } } )"},
                     {pattern,"{ { succeed , _ } , _ }"},
                     {value,{{error,{type_error,callable,{<<"test">>,12345}}},
                             {est,[],[],[],0,{db,erlog_db_dict,...}}}}]}
rvirding commented 10 years ago

It would now be better to use maps to represent JSON data. This would make it easier to use and make it easier to handle the case where you have lists of objects as data. There is jsxn which is an extension to jsx which does this.

zkessin commented 10 years ago

I think you are right, closing in favor of #38