-1

I want to create a markdown file which includes a js object. I want to add commentaries which are stored in an other object to each line.

The output should look like this:

{
  "a": "test,  //commentary1
  "b": "test2" //commentary2
}

My first intention was to rewrite the stringify function, but it's a bit tricky for edge cases.

How can I achieve this functionality in more better way?

Abdur Rahman
  • 894
  • 1
  • 11
  • 27
Kevin W.
  • 101
  • 1
  • 8

1 Answers1

0

You can opt for 2 options

  1. Add comment as keys like

    { "_comment": "comment text goes here..." }

  2. Instead of json object use json array and parse accordingly

    { "a": ["test", "commentary1"], "b": ["test2", "commentary2"] }

Tanu Garg
  • 3,007
  • 4
  • 21
  • 29