Simple Json convention for Prolog

I’ve come up with the following simple convention for moving between Prolog and Json that Postgresql and web browsers can parse.

Terms = [cell(1, 1, x), cell(1, 2, x), cell(1, 3, o),
         cell(2, 1, b), cell(2, 2, o), cell(2, 3, b),
         cell(3, 1, b), cell(3, 2, o), cell(3, 3, x),
         control(white)].
Json = [["cell", 1, 1, "x"], ["cell", 1, 2, "x"], ["cell", 1, 3, "o"],
        ["cell", 2, 1, "b"], ["cell", 2, 2, "o"], ["cell", 2, 3, "b"],
        ["cell", 3, 1, "b"], ["cell", 3, 2, "o"], ["cell", 3, 3, "x"],
        ["control", "white"]]

My code to do this translation looks like so:

atom_json(true, true) :- !.
atom_json(false, false) :- !.
atom_json(null, null) :- !. 
atom_json(Number, Number) :- number(Number), !.
atom_json(Atom, String) :- atom_string(Atom, String).
 
jsonify(AtomList, JsonArray) :-
    maplist(atom_json, AtomList, JsonArray).
 
json_terms(Json, Terms) :-
    ground(Terms), !,
    maplist(=.., Terms, List),
    maplist(jsonify, List, Json).

json_terms(Json, Terms) :-
    maplist(jsonify, List, Json),
    maplist(=.., Terms, List).

I guess if need to convert Prolog rules to Json for some reason, something more complex would be needed. But this seems the easiest way to convert Prolog facts to something other languages can read and write.

Can you discuss briefly how this compares to library(http/json) and library(http/json_convert)? Obviously your code attempts to be even more general I guess?

The provided Json in SWI Prolog seems very tied to dicts as in making Json objects {"key1": "value1", "key2": "value2", ...} accessible using nearly the same syntax in SWI Prolog.

In my case, I want to use Json as a lingua franca between Json parsers in other programming languages, using what Json calls arrays and Prolog lists, and these don’t seem to be supported by prolog_to_json (:Term, -JSONObject) and json_to_prolog (+JSON, -Term) as far as I understand them.