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).
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)
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)
Expansion of the string usually occurs at run time.
Template processor (Wikipedia)
Code examples using Quasi Quotations