This is a topic that was split off from How to avoid escaping characters in Prolog strings
The need is to create JSON for use with Cytoscape.js graphs which uses JSON to define the nodes and edges of the graph. (ref) As was done with creating nodes and edges for use with GraphViz using DCGs, the plan is to create Cytoscape.js graphs with DCGs. (ref).
Personal Notes
Supporting JSON
library(http/json): Reading and writing JSON serialization
library(http/json_convert): Convert between JSON terms and Prolog application terms
library(http/http_json): HTTP JSON Plugin module - If you are not using an HTTP server then instead look at library(http/json)
library(http/js_write): Utilities for including JavaScript
Anne’s site (JSON)
JSONLint - The JSON Validator
library(quasi_quotations): Define Quasi Quotation syntax
Why It’s Nice to be Quoted: Quasiquoting for Haskell (pdf)
Why It’s Nice to be Quoted: Quasiquoting for Prolog (pdf)
Implementing GraphQL as a Query Language for Deductive Databases in SWI–Prolog Using DCGs, Quasi Quotations, and Dicts (pdf)
Quasi-quotation (Wikipedia)
String interpolation (Wikipedia)
Expansion of the string usually occurs at run time.
Template processor (Wikipedia)
A template engine is ordinarily included as a part of a web template system or application framework, and may be used also as a preprocessor or filter.
Code examples using Quasi Quotations
https://github.com/xpxaxsxi/qqospath/blob/branch1/qqospath.pl
https://github.com/mndrix/uri_qq/blob/master/prolog/uri_qq.pl
http://www.pathwayslms.com/swipltuts/html/index.html#_inclusion
https://github.com/NaohiroTamura/graphql/blob/622ddbb111a7583a0d9edfb5b33a06e68baacdfd/prolog/graphql.pl
https://github.com/TeamSPoon/logicmoo_nlu/blob/a9924b3d14fd97bcd900e4a8cb4ceefd2d51f93e/prolog/marty_white/adv_quasiquote.pl
https://github.com/NaohiroTamura/openwhisk-runtime-prolog/blob/dc35da81020e722081c100ac14d4dcc924f8b340/samples/actions/graphql.pl
https://github.com/Hookscript/lang-prolog-swi/blob/390fa1b9e345f0e7112733953205fcf58e920769/packs/uri_qq/prolog/uri_qq.pl
https://github.com/JanWielemaker/rserve_client/blob/f5df41128164258a03158928d41eb81eeed0f24b/prolog/r/r_call.pl
https://github.com/samer--/prolog/blob/574caf40a99afcd0e6fe2b5aeda2c725cd2fcd3b/pldb/prolog/pldb_core.pl