Rough and ready thoughts about JSON as an article format

I'm just beginning to think about what a JSON article might look like as compared to the same article in XML or XHTML or just plain HTML. You might ask why, and despair at the need to understand yet another language for data storage.


My own interest stems from working with Xcode, where it is much easier to load JSON than XML. This is because the structure of JSON is so similar to the object-oriented language of Objective-C. Not only this but a growing awareness that JSON is quicker and lighter than XML when loading remotely - something that will happen more and more thanks to mobile apps - makes JSON all too tempting to consider.

There is of course conversion to think about from XML to JSON, but online tools already exist - e.g. http://jsontoxml.utilities-online.info - and more sophisticated translation can be done using Regular Expressions (which need not be particularly complex).

A simple paragraph with some italic text might look like this:

{
    "para": [
        "this is text",
        {
            "italic": "Book Title"
        },
        "More text"
    ]
}

We need the paragraph to be an array of strings and objects so that it can contain different things, like italic text, hyperlinks, note referents and citations.

Hyperlink object (suggestion):

{
    "hyperlink": {
        "href": "http://www.gylphi.co.uk",
        "title": "Gylphi Limited"
    }
}


We need hyperlinks to be their own objects with a nested object inside because not only do they have a href value, but text that is displayed and tooltips, and so on.

Citation object (suggestion):

{
    "citation": {
        "author": "smith",
        "firstname": "John",
        "title": "The Book",
        "date": 1989,
        "ISBN": 1234340392489023,
        "Amazon": "amazonID",
        "Google": "googleID",
        "iBooks": "iBooksID",
        "displayed_text": "Smith (1989)"
    }
}


The citation object also contains a nested object and this gives great scope for the amount of rich detail that could be included. I've added a "displayed_text" key to save time with complex parsing and variants, e.g. Smith (1989), (Smith, 1989), (Smith, 1989: p. 89).

Finally, this is how an article might begin to look:

{
    "article": [
        {
            "para": [
                "this is text",
                {
                    "italic": "Book Title"
                },
                "More text",
   {
    "hyperlink": {
        "href": "http://www.gylphi.co.uk",
        "title": "Gylphi Limited"
    }
}
            ]
        },
        {
            "para": [
                "this is text",
                {
                    "italic": "Book Title"
                },
                "More text", {
    "citation": {
        "author": "smith",
        "firstname": "John",
        "title": "The Book",
        "date": 1989,
        "ISBN": 1234340392489023,
        "Amazon": "amazonID",
        "Google": "googleID",
        "iBooks": "iBooksID",
        "displayed_text": "Smith (1989)"
    }
}

            ]
        }
    ]
}

I've left out things like title, abstract and so on in the name of haste, but from these basics it is possible to extrapolate for these things, as well as blockquotes, images and references, etc.

To learn more see the JSON website and to test out your own examples use JSONLint.

Forgive me if this has been addressed elsewhere (just let me know in the comments below).

Comments