The problem if I evaluate it it complains of the invalid JSON, while for other tools it is valid JSON:
Welcome to SWI-Prolog (threaded, 64 bits, version 7.6.4)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.
For built-in help, use ?- help(Topic). or ?- apropos(Word).
?- with_command("/bin/ls", "ij", O).
ERROR: Stream <stream>(0xa16800):1:2 Syntax error: json(illegal_json)
?-
% halt
If I change the "read_result" relation to:
read_result(Out, Json) :- read_string(Out, "", "", End, Json), print(Json).
It prints JSON here:
Singleton variables: [End]
Welcome to SWI-Prolog (threaded, 64 bits, version 7.6.4)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.
For built-in help, use ?- help(Topic). or ?- apropos(Word).
?- with_command("/bin/ls", "ij", O).
"{\"core\":{\"type\":\"DYN (Shared object
file)\",\"file\":\"/bin/ls\",\"fd\":3,\"size\":157896,\"humansz\":\"154.2K\",\"iorw\":false,\"mode\":\"r-x\",\"obsz\":0,\"block\":256,\"format\":\"elf64\"},\"bin\":{\"arch\":\"x86\",\"binsz\":155969,\"bintype\":\"elf\",\"bits\":64,\"canary\":true,\"class\":\"ELF64\",\"compiled\":\"\",\"crypto\":false,\"dbg_file\":\"\",\"endian\":\"little\",\"havecode\":true,\"guid\":\"\",\"intrp\":\"/lib64/ld-linux-x86-64.so.2\",\"lang\":\"c\",\"linenum\":false,\"lsyms\":false,\"machine\":\"AMD
x86-64
architecture\",\"maxopsz\":16,\"minopsz\":1,\"nx\":true,\"os\":\"linux\",\"pcalign\":0,\"pic\":true,\"relocs\":false,\"relro\":\"full\",\"rpath\":\"NONE\",\"static\":false,\"stripped\":true,\"subsys\":\"linux\",\"va\":true,\"checksums\":{}}}\n"
O = "{\"core\":{\"type\":\"DYN (Shared object
file)\",\"file\":\"/bin/ls\",\"fd\":3,\"size\":157896,\"humansz\":\"154.2K\",\"iorw\":false,\"mode\":\"r-x\",\"obsz\":0,\"block\":256,\"format\":\"elf64\"},\"bin\":{\"arch\":\"x86\",\"binsz\":155969,\"bintype\":\"elf\",\"bits\":64,\"canary\":true,\"class\":\"ELF64\",\"compiled\":\"\",\"crypto\":false,\"dbg_file\":\"\",\"endian\":\"little\",\"havecode\":true,\"guid\":\"\",\"intrp\":\"/lib64/ld-linux-x86-64.so.2\",\"lang\":\"c\",\"linenum\":false,\"lsyms\":false,\"machine\":\"AMD
x86-64
architecture\",\"maxopsz\":16,\"minopsz\":1,\"nx\":true,\"os\":\"linux\",\"pcalign\":0,\"pic\":true,\"relocs\":false,\"relro\":\"full\",\"rpath\":\"NONE\",\"static\":false,\"stripped\":true,\"subsys\":\"linux\",\"va\":true,\"checksums\":{}}}\n".
|