Closed dram closed 5 years ago
When trying to convert JSON objects to Mercury maps, a confusing error will be reported, i.e.:
conversion to tree234.tree234(string, list.list(string)): argument is object, expected object
Following is demo code:
:- module test. :- interface. :- import_module io. :- pred main(io::di, io::uo) is det. :- implementation. :- import_module json. :- import_module list. :- import_module map. :- import_module maybe. :- import_module string. main(!IO) :- Result = json.from_json( json.det_from_string( "{\"foo\": [\"a\", \"b\"], \"bar\": [\"c\"]}")), ( Result = maybe.ok(Data : map(string, list(string))), io.write_line(Data, !IO) ; Result = maybe.error(Error), io.write_line(Error, !IO) ).
Tested Mercury version is:
Mercury Compiler, version rotd-2019-08-16, on x86_64-pc-linux-gnu
Thanks for reporting that, the error message for that case is supposed to read:
argument is object, expected array
(It was also wrong for bimaps and retrees.). I've pushed a fix for it.
When trying to convert JSON objects to Mercury maps, a confusing error will be reported, i.e.:
Following is demo code:
Tested Mercury version is: