const rawPostJson = getRawJson('~/path/to/post_data.json');
const rawCommentJson = getRawJson('~/path/to/comment_data.json');
const mySchema = getRawJson('~/path/to/schema.json');

//starts empty maybe?
const jsonGraphData = getRawJson('~/path/to/graphData.json')

// returns functions for the different types allowed by the schema, with the destination file baked in
const { addPoster, addPost, addCharacter } = schemaFiller.fromSchema(mySchema, jsonGraphData);

const extractedPosts = doSomethingClever(rawPostJson).map(post => { author, url, character, subtype });

const extractedComments = doSomethingElseClever(rawCommentJson).map(post => { author, url, character, subtype });

extractedPosts.forEach(post => {
  // converts subtype from LFA/RF to Requester/Artist
  addPoster(post.author, post.url, post.subtype);
  addPost(post.author, post.url, post.character, post.subtype);
   //  converts subtype from LFA/RF to Owner/Artist
  addCharacter(post.author, post.subtype);
});
extractedComments.forEach(comment => {
  // converts subtype from LFA/RF to Requester/Artist
  addPoster(comment.author, comment.url, comment.subtype);
  addPost(comment.author, post.url, post.character, post.subtype);
   //  converts subtype from LFA/RF to Owner/Artist
  addCharacter(comment.author, comment.subtype);
});

schemaFiller.writeToFile(addPoster, addPost, addCharacter);
Edit

Pub: 31 Jul 2022 00:05 UTC

Edit: 31 Jul 2022 00:10 UTC

Views: 153