Structured Text in JSON

I was looking for a way to capture structured text (sections, paragraphs, accent, lists, etc.) in JSON, but I haven't found anything yet. Any suggestions? (Markdown crossed my mind, but there might be something better.)

+5
source share
3 answers

HTML is a well established way to describe structured text in text format (!). Markdown (as you mentioned) will also work.

My opinion is that your best bet is probably to use some kind of plain text markup such as these options and put the text in a single JSON string string. Depending on your application, it might make sense to have an array of sections containing an array of paragraphs containing an array of sections normal / bold / list, etc. However, in the general case, I believe that good old-fashioned blocks are markup ironically, to be cleaner and more scalable due to the simplicity of their passage, as well as well-designed libraries for full-scale parsing, if necessary.

+5
source

How about something like this:

[ { "heading": "Foobar Example" },
  { "paragraph":
    [
      "This is normal text, followed by... ",
      { "bold": "some bold text" },
      "etc."
    ]
  }
]

I.e:

  • use a string for plain text without formatting or other text;

  • , ;

  • , , - , .

+5

There is also a specification that can fulfill this Markdown Syntax for object notation (MSON)

Not sure if you have a problem with spec implementation, but it seems to be an option.

0
source

All Articles