I’m trying to convert an arbitrary Prolog term (which could literally be any legal Prolog term) to a JSON string. My personal ideal format would have a Prolog term be represented as a JSON dict with one key/value: the key is the name of the predicate and the value is a list containing args. Lists just become a JSON list. Like this:
But I have some flexibility on other transformations if need be.
For some reason I’m really struggling to understand how this works in the system. It appears as though:
library(http/json)is for conversion between a JSON String and a canonical Prolog term structure (but no ability to deal with arbitrary Prolog terms)
library(library(http/json_convert)is for creating mappings between your application specific Prolog terms and your own, custom, JSON expression of them. It appears daunting to define enough to do arbitrary Prolog terms.
library(library(term_to_json)seems to map arbitrary Prolog terms to a canonical JSON format that is different than the one library(http/json) uses?
Do I have this right? Are there other options in the system (beyond
term_to_json/2) that can convert arbitrary Prolog terms to a JSON string somehow?
I’m just trying to see what options are available before I go write a bunch of custom code…