How to get options from the json request for pengine_create()

I created the Pengine object, and it sends a request to /pengine/create in the json format.

var pengine = new Pengine({});

This is my http handler. I use library(http/json_convert) to convert the request, but I am getting only 2 params in the term json([src_text=,format=json]). When I just print the JSON term through json_reply I see the pengine property (see the picture below)

pengines_create(Request) :-
	http_read_json(Request, JSON),
	json_to_prolog(JSON, Term),
	format('Content-type: text/html~n~n', []),
	format('~w', [Term]).

Screenshot from 2020-11-09 11-50-07

I don’t really get the question. Why define a pengines create handler? That is part of library(pengines). The question may also be about json_to_prolog/2.

json_to_prolog/2 should typically be considered old school. These days use http_read_json_dict/2 and use the dict. The conversion was intended to convert e.g. {type: point, x:10, y:30} into point(x,y). That may still have some value in some scenarios. Possibly dicts_to_compounds/4 is more useful and easier to understand.

Maybe we should deprecate json_to_prolog/2?

I am trying to initiate the pengines like this:

pengines_create(Request) :-
    %get options
	pengine_create(Options).

But at first I need to get the options. So I was trying to parse json into prolog’s terms.
Is that correct?

http_read_json_dict/2 gives the same result.

I miss the overall picture. The HTTP binding for creating pengines is in library(pengines). All you need to do is create an HTTP server and load library(pengines) to have a working pengines server. The minimum is this

:- use_module(library(http/http_server)).
:- use_module(library(pengines)).

server :-
    http_server([port(8080)]).

After which you can access the pengines at http://localhost:8080/pengine/create

Yes, it works. Thanks