This post breaks down at a code level a structure for JSON books and chapters. For a clear explanation of why a JSON book and article format would be a good thing see Why JSON as an article and book article format?
{
"Chapter 1": [
[
"A paragraph with normal formatting and ",
{
"i": "italic text"
},
" that contains a continuation.",
{
"fn": [
"a footnote"
]
},
" Followed by",
{
"ct": [
"a citation, i.e. a cross-reference to the ref list that will be used as a link"
]
},
{
"fn": [
"a footnote with a citation inside",
{
"ct": [
"a citation, i.e. a cross-reference to the ref list that will be used as a link"
]
}
]
}
],
[
"The next paragraph."
]
]
}
1. The root values of a book written using JavaScript Object Notation (JSON) should be the language(s)
{
"EN": {},
"FR": {},
"DE": {}
}
"EN": {},
"FR": {},
"DE": {}
}
2. Inside the languages will be the editions
{
"EN": {
"1980": {},
"2002": {}
},
"FR": {
"2002": {}
},
"DE": {
"1970": {},
"2009": {}
}
}
"EN": {
"1980": {},
"2002": {}
},
"FR": {
"2002": {}
},
"DE": {
"1970": {},
"2009": {}
}
}
3. Inside each edition will be the short titles of the chapters, which will be an array – this array can hold objects {}, strings "", and arrays []
{
"EN": {
"1980": {
"Chapter 1": [],
"Chapter 2": []
},
"2002": {
"Chapter 1": [],
"Chapter 2": [],
"Chapter 3": [],
"Chapter 4": []
}
},
"FR": {
"2002": {
"Chapter 1": [],
"Chapter 2": [],
"Chapter 3": [],
"Chapter 4": []
}
},
"DE": {
"1970": {
"Chapter 1": [],
"Chapter 2": [],
"Chapter 3": []
},
"2009": {
"Chapter 1": [],
"Chapter 2": [],
"Chapter 3": [],
"Chapter 4": []
}
}
}
4. Inside the edition objects will also be objects such as running heads, title, subtitle, and copyright details. These might look like this (although running heads, for example, may well be chapter specific and be included in the chapter object array – in which case they would override any global running heads):
{
"rh": [
"this is a verso running-head",
"this is a recto running head"
]
},
{
"title": [
"title"
]
},
{
"subtitle": [
"subtitle"
]
},
{
"copyright": [
"copyright details"
]
}
"rh": [
"this is a verso running-head",
"this is a recto running head"
]
},
{
"title": [
"title"
]
},
{
"subtitle": [
"subtitle"
]
},
{
"copyright": [
"copyright details"
]
}
5. In an edited collection, there is likely to be author names and affiliations, the value of each of which will be an object containing an array of strings (situated inside the chapter arrays)
{
"authors": [
"author1",
"author2"
]
},
{
"affiliations": [
"aff1",
"aff2"
]
}
"authors": [
"author1",
"author2"
]
},
{
"affiliations": [
"aff1",
"aff2"
]
}
6. It is important that all textual elements within the body of a chapter or article are able to contain emphasis such as italics and bold, in order to achieve this I propose that all textual elements are arrays and that emphasised text is given as an object. This use of arrays would apply to headings as well:
{
"h1": [
" A heading with ",
{
"i": "italic text"
},
"and",
{
"b": "bold text"
}
]
}
"h1": [
" A heading with ",
{
"i": "italic text"
},
"and",
{
"b": "bold text"
}
]
}
7. "Normal" paragraphs with a generic global style should be arrays (not objects) within the "stream" of the chapter (but will contain objects such as emphasised text, footnotes, and citations)
{
"Chapter 1": [
[
"A paragraph with normal formatting and ",
{
"i": "italic text"
},
" that contains a continuation.",
{
"fn": [
"a footnote"
]
},
" Followed by",
{
"ct": [
"a citation, i.e. a cross-reference to the ref list that will be used as a link"
]
},
{
"fn": [
"a footnote with a citation inside",
{
"ct": [
"a citation, i.e. a cross-reference to the ref list that will be used as a link"
]
}
]
}
],
[
"The next paragraph."
]
]
}
8. Objects such as images that typically come between paragraphs will sit between the paragraph arrays (although they could easily be a part of the paragraph array should the situation arise)
{
"img": [
"link to image",
[
"an image caption",
{
"i": "italic text"
}
]
]
}
{
"img": [
"link to image",
[
"an image caption",
{
"i": "italic text"
}
]
]
}
9. A reference (or works cited) list will be a named object that links back to citations through its keys. The references themselves will be arrays for the reasons given above about emphasised text (they may also include hyperlinks, etc.)
{
"references": {
"citation1": [
"reference text",
{
"i": "this is italic text"
},
"remaining reference text"
],
"citation2": [
"reference text",
{
"i": "this is italic text"
},
"remaining reference text"
]
}
}
"references": {
"citation1": [
"reference text",
{
"i": "this is italic text"
},
"remaining reference text"
],
"citation2": [
"reference text",
{
"i": "this is italic text"
},
"remaining reference text"
]
}
}
10. An index can be constructed in the follow way, where the title of the index is index and the entries are keys, and the page numbers are an array of values. Sub-entries will be objects nested in these arrays (for further discussion see Hashtags not Hyperlinks: The index of the future)
{
"index": {
"banana": [
21,
22,
23,
52
],
"books": [
63.65,
89,
{
"electronic": [
78,
93,
101
]
}
]
}
}
"index": {
"banana": [
21,
22,
23,
52
],
"books": [
63.65,
89,
{
"electronic": [
78,
93,
101
]
}
]
}
}
11. It would be valid to replace the contents of a chapter, edition or language with a (relative) link referencing the location of the material should the data be too large for a single file, and to create chapter and edition objects as standalone items. This may well prove desirable and supply the opportunity to combine HTML5/XHTML/XML and JSON in a single book (for transition or longer-term purposes)
It is not the expectation that publishers start converting content to JSON immediately, but instead that by using JSON as the framework (i.e. manifest and structure, similar in concept to the HPub format which uses JSON for its manifest file and HTML5 for its content), and in areas such as the index, huge advantages would be opened. Enabling the book or chapter level content to remain in current formats, while at the same time opening the opportunity for JSON to advance into these areas if and when it is deemed necessary.
This blogpost presents an ideal, and a starting point for a discussion, of what a book built (in its entirety) around JSON might look like, and thus remove the concept of a book relying on web-browser technology (HTML and JavaScript) as a rule and instead having the opportunity to interface more directly with any language on the web or that it natively encounters on a device (e.g. iOS's Core Text) in order for optimisation and speed to go well beyond what we currently experience. This shouldn't remove the option for the current approach of ebooks rendering web content, but vice versa the web content approach shouldn't stand in the way of ebooks becoming first class citizens on any device.
For further discussion of this point, see earlier post.
For further discussion of this point, see earlier post.
12. For completeness, this is an abbreviated example of how a book following these rules would be arranged if constructed in a single file entirely from JSON:
{
"EN": {
"edition1980": {
"chapter1": [
{
"rh": [
"this is a verso running-head",
"this is a recto running head"
]
},
{
"title": [
"title"
]
},
{
"subtitle": [
"subtitle"
]
},
{
"authors": [
"author1",
"author2"
]
},
{
"affiliations": [
"aff1",
"aff2"
]
},
{
"h1": [
" A heading with ",
{
"i": "italic text"
},
"and",
{
"b": "bold text"
}
]
},
[
"Paragraph with normal formatting and ",
{
"i": "italic text"
}
],
[
"Another paragraph with normal formatting, ",
{
"i": "italic text"
},
"and the rest.",
{
"fn": [
"a footnote"
]
},
"Followed by",
{
"ct": [
"a citation, i.e. a cross-reference to the ref list that will be used as a link"
]
},
{
"fn": [
"a footnote with a citation inside",
{
"ct": [
"a citation, i.e. a cross-reference to the ref list that will be used as a link"
]
}
]
}
],
{
"img": [
"link to image",
[
"an image caption",
{
"i": "italic text"
}
]
]
},
{
"references": {
"citation1": [
"reference text",
{
"i": "this is italic text"
},
"remaining reference text"
],
"citation2": [
"reference text",
{
"i": "this is italic text"
},
"remaining reference text"
]
}
}
],
"chapter2": [
{
"h1": [
" A heading with ",
{
"i": "italic text"
},
"and",
{
"b": "bold text"
}
]
},
[
"Paragraph with normal formatting and",
{
"i": "italic text"
}
],
[
"Paragraph with normal formatting, ",
{
"i": "italic text"
},
"and the rest.",
{
"fn": [
"a footnote"
]
},
"Followed by",
{
"ct": [
"a citation, i.e. a cross-reference to the ref list that will be used as a link"
]
},
{
"fn": [
"a footnote with a citation inside",
{
"ct": [
"a citation, i.e. a cross-reference to the ref list that will be used as a link"
]
}
]
}
],
{
"img": [
"link to image",
[
"an image caption",
{
"i": "italic text"
}
]
]
},
{
"references": {
"citation1": [
"reference text",
{
"i": "this is italic text"
},
"remaining reference text"
],
"citation2": [
"reference text",
{
"i": "this is italic text"
},
"remaining reference text"
]
}
}
],
"index": {
"banana": [
21,
22,
23,
52
],
"books": [
63.65,
89,
{
"electronic": [
78,
93,
101
]
}
]
}
},
"edition2002": {
"chapter1": [
{
"rh": [
"this is a verso running-head",
"this is a recto running head"
]
},
{
"title": [
"title"
]
},
{
"subtitle": [
"subtitle"
]
},
{
"authors": [
"author1",
"author2"
]
},
{
"affiliations": [
"aff1",
"aff2"
]
},
{
"h1": [
" A heading with ",
{
"i": "italic text"
},
"and",
{
"b": "bold text"
}
]
},
[
"Paragraphs with normal formatting.",
{
"i": "italic text"
}
],
[
"Paragraph with normal formatting, ",
{
"i": "italic text"
},
" and the rest.",
{
"fn": [
"a footnote"
]
},
"Followed by",
{
"ct": [
"a citation, i.e. a cross-reference to the ref list that will be used as a link"
]
},
{
"fn": [
"a footnote with a citation inside",
{
"ct": [
"a citation, i.e. a cross-reference to the ref list that will be used as a link"
]
}
]
}
],
{
"img": [
"link to image",
[
"an image caption",
{
"i": "italic text"
}
]
]
},
{
"references": {
"citation1": [
"reference text",
{
"i": "this is italic text"
},
"remaining reference text"
],
"citation2": [
"reference text",
{
"i": "this is italic text"
},
"remaining reference text"
]
}
}
],
"chapter2": [
{
"h1": [
" A heading with ",
{
"i": "italic text"
},
"and",
{
"b": "bold text"
}
]
},
[
"Paragraphs with normal formatting.",
{
"i": "italic text"
}
],
[
"Paragraphs with normal formatting.",
{
"i": "italic text"
},
"Paragraphswithnormalformatting.",
{
"fn": [
"a footnote"
]
},
"Followed by",
{
"ct": [
"a citation, i.e. a cross-reference to the ref list that will be used as a link"
]
},
{
"fn": [
"a footnote with a citation inside",
{
"ct": [
"a citation, i.e. a cross-reference to the ref list that will be used as a link"
]
}
]
}
],
{
"img": [
"link to image",
[
"an image caption",
{
"i": "italic text"
}
]
]
},
{
"references": {
"citation1": [
"reference text",
{
"i": "this is italic text"
},
"remaining reference text"
],
"citation2": [
"reference text",
{
"i": "this is italic text"
},
"remaining reference text"
]
}
}
]
},
"index": {
"banana": [
24,
26,
28,
52
],
"books": [
63.65,
89,
{
"electronic": [
78,
93,
101
]
}
]
}
},
"FR": {
"edition": {
"chapter1": [
{
"rh": [
"this is a verso running-head",
"this is a recto running head"
]
},
{
"title": [
"title"
]
},
{
"subtitle": [
"subtitle"
]
},
{
"authors": [
"author1",
"author2"
]
},
{
"affiliations": [
"aff1",
"aff2"
]
},
{
"h1": [
" A heading with ",
{
"i": "italic text"
},
"and",
{
"b": "bold text"
}
]
},
[
"Paragraph with normal formatting and ",
{
"i": "italic text"
}
],
[
"Paragraph with normal formatting, ",
{
"i": "italic text"
},
"and the rest.",
{
"fn": [
"a footnote"
]
},
"Followed by",
{
"ct": [
"a citation, i.e. a cross-reference to the ref list that will be used as a link"
]
},
{
"fn": [
"a footnote with a citation inside",
{
"ct": [
"a citation, i.e. a cross-reference to the ref list that will be used as a link"
]
}
]
}
],
{
"img": [
"link to image",
[
"an image caption",
{
"i": "italic text"
}
]
]
},
{
"references": {
"citation1": [
"reference text",
{
"i": "this is italic text"
},
"remaining reference text"
],
"citation2": [
"reference text",
{
"i": "this is italic text"
},
"remaining reference text"
]
}
}
],
"chapter2": [
{
"h1": [
" A heading with ",
{
"i": "italic text"
},
"and",
{
"b": "bold text"
}
]
},
[
"Paragraph with normal formatting and ",
{
"i": "italic text"
}
],
[
"Paragraph with normal formatting, ",
{
"i": "italic text"
},
"and the rest.",
{
"fn": [
"a footnote"
]
},
"Followed by",
{
"ct": [
"a citation, i.e. a cross-reference to the ref list that will be used as a link"
]
},
{
"fn": [
"a footnote with a citation inside",
{
"ct": [
"a citation, i.e. a cross-reference to the ref list that will be used as a link"
]
}
]
}
],
{
"img": [
"link to image",
[
"an image caption",
{
"i": "italic text"
}
]
]
},
{
"references": {
"citation1": [
"reference text",
{
"i": "this is italic text"
},
"remaining reference text"
],
"citation2": [
"reference text",
{
"i": "this is italic text"
},
"remaining reference text"
]
}
}
]
}
}
}
"EN": {
"edition1980": {
"chapter1": [
{
"rh": [
"this is a verso running-head",
"this is a recto running head"
]
},
{
"title": [
"title"
]
},
{
"subtitle": [
"subtitle"
]
},
{
"authors": [
"author1",
"author2"
]
},
{
"affiliations": [
"aff1",
"aff2"
]
},
{
"h1": [
" A heading with ",
{
"i": "italic text"
},
"and",
{
"b": "bold text"
}
]
},
[
"Paragraph with normal formatting and ",
{
"i": "italic text"
}
],
[
"Another paragraph with normal formatting, ",
{
"i": "italic text"
},
"and the rest.",
{
"fn": [
"a footnote"
]
},
"Followed by",
{
"ct": [
"a citation, i.e. a cross-reference to the ref list that will be used as a link"
]
},
{
"fn": [
"a footnote with a citation inside",
{
"ct": [
"a citation, i.e. a cross-reference to the ref list that will be used as a link"
]
}
]
}
],
{
"img": [
"link to image",
[
"an image caption",
{
"i": "italic text"
}
]
]
},
{
"references": {
"citation1": [
"reference text",
{
"i": "this is italic text"
},
"remaining reference text"
],
"citation2": [
"reference text",
{
"i": "this is italic text"
},
"remaining reference text"
]
}
}
],
"chapter2": [
{
"h1": [
" A heading with ",
{
"i": "italic text"
},
"and",
{
"b": "bold text"
}
]
},
[
"Paragraph with normal formatting and",
{
"i": "italic text"
}
],
[
"Paragraph with normal formatting, ",
{
"i": "italic text"
},
"and the rest.",
{
"fn": [
"a footnote"
]
},
"Followed by",
{
"ct": [
"a citation, i.e. a cross-reference to the ref list that will be used as a link"
]
},
{
"fn": [
"a footnote with a citation inside",
{
"ct": [
"a citation, i.e. a cross-reference to the ref list that will be used as a link"
]
}
]
}
],
{
"img": [
"link to image",
[
"an image caption",
{
"i": "italic text"
}
]
]
},
{
"references": {
"citation1": [
"reference text",
{
"i": "this is italic text"
},
"remaining reference text"
],
"citation2": [
"reference text",
{
"i": "this is italic text"
},
"remaining reference text"
]
}
}
],
"index": {
"banana": [
21,
22,
23,
52
],
"books": [
63.65,
89,
{
"electronic": [
78,
93,
101
]
}
]
}
},
"edition2002": {
"chapter1": [
{
"rh": [
"this is a verso running-head",
"this is a recto running head"
]
},
{
"title": [
"title"
]
},
{
"subtitle": [
"subtitle"
]
},
{
"authors": [
"author1",
"author2"
]
},
{
"affiliations": [
"aff1",
"aff2"
]
},
{
"h1": [
" A heading with ",
{
"i": "italic text"
},
"and",
{
"b": "bold text"
}
]
},
[
"Paragraphs with normal formatting.",
{
"i": "italic text"
}
],
[
"Paragraph with normal formatting, ",
{
"i": "italic text"
},
" and the rest.",
{
"fn": [
"a footnote"
]
},
"Followed by",
{
"ct": [
"a citation, i.e. a cross-reference to the ref list that will be used as a link"
]
},
{
"fn": [
"a footnote with a citation inside",
{
"ct": [
"a citation, i.e. a cross-reference to the ref list that will be used as a link"
]
}
]
}
],
{
"img": [
"link to image",
[
"an image caption",
{
"i": "italic text"
}
]
]
},
{
"references": {
"citation1": [
"reference text",
{
"i": "this is italic text"
},
"remaining reference text"
],
"citation2": [
"reference text",
{
"i": "this is italic text"
},
"remaining reference text"
]
}
}
],
"chapter2": [
{
"h1": [
" A heading with ",
{
"i": "italic text"
},
"and",
{
"b": "bold text"
}
]
},
[
"Paragraphs with normal formatting.",
{
"i": "italic text"
}
],
[
"Paragraphs with normal formatting.",
{
"i": "italic text"
},
"Paragraphswithnormalformatting.",
{
"fn": [
"a footnote"
]
},
"Followed by",
{
"ct": [
"a citation, i.e. a cross-reference to the ref list that will be used as a link"
]
},
{
"fn": [
"a footnote with a citation inside",
{
"ct": [
"a citation, i.e. a cross-reference to the ref list that will be used as a link"
]
}
]
}
],
{
"img": [
"link to image",
[
"an image caption",
{
"i": "italic text"
}
]
]
},
{
"references": {
"citation1": [
"reference text",
{
"i": "this is italic text"
},
"remaining reference text"
],
"citation2": [
"reference text",
{
"i": "this is italic text"
},
"remaining reference text"
]
}
}
]
},
"index": {
"banana": [
24,
26,
28,
52
],
"books": [
63.65,
89,
{
"electronic": [
78,
93,
101
]
}
]
}
},
"FR": {
"edition": {
"chapter1": [
{
"rh": [
"this is a verso running-head",
"this is a recto running head"
]
},
{
"title": [
"title"
]
},
{
"subtitle": [
"subtitle"
]
},
{
"authors": [
"author1",
"author2"
]
},
{
"affiliations": [
"aff1",
"aff2"
]
},
{
"h1": [
" A heading with ",
{
"i": "italic text"
},
"and",
{
"b": "bold text"
}
]
},
[
"Paragraph with normal formatting and ",
{
"i": "italic text"
}
],
[
"Paragraph with normal formatting, ",
{
"i": "italic text"
},
"and the rest.",
{
"fn": [
"a footnote"
]
},
"Followed by",
{
"ct": [
"a citation, i.e. a cross-reference to the ref list that will be used as a link"
]
},
{
"fn": [
"a footnote with a citation inside",
{
"ct": [
"a citation, i.e. a cross-reference to the ref list that will be used as a link"
]
}
]
}
],
{
"img": [
"link to image",
[
"an image caption",
{
"i": "italic text"
}
]
]
},
{
"references": {
"citation1": [
"reference text",
{
"i": "this is italic text"
},
"remaining reference text"
],
"citation2": [
"reference text",
{
"i": "this is italic text"
},
"remaining reference text"
]
}
}
],
"chapter2": [
{
"h1": [
" A heading with ",
{
"i": "italic text"
},
"and",
{
"b": "bold text"
}
]
},
[
"Paragraph with normal formatting and ",
{
"i": "italic text"
}
],
[
"Paragraph with normal formatting, ",
{
"i": "italic text"
},
"and the rest.",
{
"fn": [
"a footnote"
]
},
"Followed by",
{
"ct": [
"a citation, i.e. a cross-reference to the ref list that will be used as a link"
]
},
{
"fn": [
"a footnote with a citation inside",
{
"ct": [
"a citation, i.e. a cross-reference to the ref list that will be used as a link"
]
}
]
}
],
{
"img": [
"link to image",
[
"an image caption",
{
"i": "italic text"
}
]
]
},
{
"references": {
"citation1": [
"reference text",
{
"i": "this is italic text"
},
"remaining reference text"
],
"citation2": [
"reference text",
{
"i": "this is italic text"
},
"remaining reference text"
]
}
}
]
}
}
}
Comments
Post a Comment