0

So having such normalized Postgres 13/14 graph of item joins:

CREATE TABLE items (
  item_id     serial PRIMARY KEY,
  title text
);
CREATE TABLE joins (
  id          serial PRIMARY KEY,
  item_id     int,
  child_id    int
);
INSERT INTO items (item_id,title) VALUES
  (1,'PARENT'),
  (2,'LEVEL 2'),
  (3,'LEVEL 3.1'),
  (4,'LEVEL 4.1'),
  (5,'LEVEL 4.2'),
  (6,'LEVEL 3.2');
INSERT INTO joins (item_id, child_id) VALUES
  (1,2),
  (2,3),
  (3,2),
  (3,5),
  (2,6);

How to turn it into a JSON Graph Format document containing item columns as fields?

3
  • What database and what version ? And what json format ? Do you mean GraphSON ? Or some custom notation, and if so you need to describe it - or better, give an example of the output you expect Jul 24, 2021 at 10:57
  • Also how do you want the JSON result ? As a JSON object in your database (assuming the database allows that). Or as a file ? Jul 24, 2021 at 11:02
  • As a JSON JGF (or similar) object output
    – Blender
    Jul 24, 2021 at 17:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.