JSON
Last updated at 7:22 pm UTC on 5 November 2018
http://www.json.org/
JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.
JSON is built on two structures:
- A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
- An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.
JSON serialization
http://www.squeaksource.com/JSON.html
MCHttpRepository
location: 'http://www.squeaksource.com/JSON'
user: ''
password: ''
For version http://www.squeaksource.com/JSON/JSON-tonyg.39.mcz
all tests green in Squeak 5.1. The main object is JsonObject.
see also STON
Notes 2010
JSON-hjh.32
Author: Hannes Hirzel
Ancestors: JSON-rh.31
In the project SCouchDB a copy of JSON is maintained by Igor Stasenko
and Radoslav Hodnicak.
This merges part of the changes back, in particular
SCouchDB project
JSON-Igor.Stasenko.28
JSON-Igor.Stasenko.29
JSON-rh.30
JSON-rh.31
Main changes
1. JsonObject is now a subclass of Dictionary instead of Object. So
there is no need to implement the Dictionary interface.
2. Fix for converting Unicode characters to \uNNNN format (missing
padding to 4 characters)
No further changes
The SCouchDB project contains more changes in the copy of the JSON package.
I did not go further in merging because in SCouchDB / JSON-rh.32
Radoslav Hodnicak introduces an instance variable 'converter'
which is initialized to
converter := UTF8TextConverter new
Igor Stasenko, Levente Uzonyi and Hannes Hirzel agreed that the UTF8
conversion does not belong into the JSON package
http://lists.squeakfoundation.org/pipermail/squeak-dev/2010-May/150497.html
Levente Uzonyi:
You only need to convert the characters to UTF-8, because you're
sending them over the network to a server, and Unicode characters have
to be converted to bytes someway. So the JSON printer shouldn't do any
conversion by default except for escaping. The only problem is that
escaping is not done as the spec requires it, but that's easy to fix.
http://www.json.org/
A string is a collection of zero or more Unicode characters, wrapped
in double quotes, using backslash escapes. A character is represented
as a single character string. A string is very much like a C or Java
string.
About escaping Unicode characters
Actually escaping Unicode characters to
\uNNNN
is not necessary for characters with codes >127 in case of an upload
to a CouchDB. But this version does it.
In case you want to patch this change method
Json class escapeForCharacter: c
Test case see WebClient, JSON and couchDB
ToDo add example using the rijksmuseum API.