Skip to content

Commit

Permalink
13 May 2010: Igor.Stasenko from Squeak: - deal with character escaping
Browse files Browse the repository at this point in the history
7 April 2010: Igor.Stasenko from Squeak: - changed Json parser to use #peekFor: ,
 where its appropriate
- wiped out any uft8 conversion code. i.e. parser assuming that input stream performs any required conversions beforehead

7 April 2010: Igor.Stasenko from Squeak: merge with rh.32

21 March 2010: rh from Squeak: added handling of utf8 encoded input data

2 March 2010: rh from Squeak: fix for converting unicode characters to \uNNNN format (missing padding to 4 characters)

1 March 2010: rh from Squeak: made JsonObject behave more like javascript objects (return nil for non-existing slot, instead of DNU)

12 January 2010: Igor.Stasenko from Squeak: - extending Object with #asJsonString

8 January 2010: Igor.Stasenko from Squeak: - my branch of SqS/JSON project with a couple of optimizations

25 December 2009: dkb from Squeak: Replace a number of _ assignments with :=

19 November 2009: matthias.berth from Squeak: Added Association>>jsonWriteOn: This makes it easier to write key-value pairs, for example:

  {#date -> document date asString.
	#author -> document author name.
	#title -> document tile}
		do: [:each | each jsonWriteOn: aStream]
		separatedBy: [aStream nextPutAll: ', '].

The association's key will be converted to a string (using #asString), the value must understand  #jsonWriteOn: .

21 August 2009: tonyg from Squeak: Merge avi.24 with ul.15, fix the tests, rudimentary (and possibly incorrect?) support for non-ASCII characters in strings, Improvements to JsonObject to get it past the tests,

10 May 2008: avi from Squeak: adding to the dip repo

4 November 2008: ul from Squeak: - fix: Control characters are escaped.
- enh: rendering time decreased (especially for strings)
- unnecessary spaces after commas and columns are not rendered

23 March 2008: avi from Squeak: for ben

7 October 2007: djr from Squeak: Only reset the stream after setting it if it responds to #reset

20 March 2008: avi from Squeak: Collection>>jsonWriteOn:

5 July 2007: aesp from Squeak: fixed bug with passed stream position over end, added simple unicode \uXXXX unescaping while reading json

16 March 2008: avi from Squeak: #properties accessor

18 April 2006: sp from Squeak: empty log message

2 August 2007: cwp from Squeak: Bugfix: JsonObject>>at:ifAbsent: was answering the association, rather than the value.

30 November 2005: tonyg from Squeak: Simple bean-like instance-variable save utility.

14 July 2007: cwp from Squeak: merge

30 November 2005: tonyg from Squeak: Abstract away the implementation detail (the syntax) of writing constructor JSON values.

14 July 2007: cwp from Squeak: JsonObject now maintains the order of its properties, so that it can be serialized consistently.

21 May 2007: cwp from Squeak: Add a method for utf-8 encoding.

29 November 2005: tonyg from Squeak: Test cases for missing constructors.

23 March 2007: cwp from Squeak: Added couple extension methods.

29 November 2005: tonyg from Squeak: Support constructor notation (@Keyword value).

21 October 2006: cwp from Squeak: Added a JsonObject with convenience accessors implemented via DNU.

24 August 2005: tonyg from Squeak: Add 'mimeType' class method

19 October 2006: cwp from Squeak: Tests fixed to run in Squeak 3.7.

17 August 2005: tonyg from Squeak: Deal with characters requiring escaping in strings being encoded to JSON.

17 August 2005: tonyg from Squeak: Support exponents in numeric syntax.

17 August 2005: tonyg from Squeak: Use a fresh string for each #render: call, instead of a literal empty string.

17 August 2005: tonyg from Squeak: Added Json class>>render:

17 August 2005: tonyg from Squeak: Implement writing, via method jsonWriteOn:.

17 August 2005: tonyg from Squeak: Initial revision. Parsing seems to work OK.
  • Loading branch information
timfel committed Jun 14, 2010
0 parents commit e43dbc6
Show file tree
Hide file tree
Showing 18 changed files with 616 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Extensions/Association.st
@@ -0,0 +1,13 @@
Association extend [

jsonWriteOn: aStream [
<category: '*JSON-writing'>
self key asString jsonWriteOn: aStream.
aStream
nextPut: $:;
space.
self value jsonWriteOn: aStream
]

]

14 changes: 14 additions & 0 deletions Extensions/Collection.st
@@ -0,0 +1,14 @@
Collection extend [

jsonWriteOn: aStream [
"By default, use array braces"

<category: '*json'>
aStream nextPut: $[.
self do: [:each | each jsonWriteOn: aStream]
separatedBy: [aStream nextPut: $,].
aStream nextPut: $]
]

]

18 changes: 18 additions & 0 deletions Extensions/Dictionary.st
@@ -0,0 +1,18 @@
Dictionary extend [

jsonWriteOn: aStream [
<category: '*JSON-writing'>
| needComma |
needComma := false.
aStream nextPut: ${.
self associationsDo:
[:assoc |
needComma ifTrue: [aStream nextPut: $,] ifFalse: [needComma := true].
assoc key jsonWriteOn: aStream.
aStream nextPut: $:.
assoc value jsonWriteOn: aStream].
aStream nextPut: $}
]

]

9 changes: 9 additions & 0 deletions Extensions/False.st
@@ -0,0 +1,9 @@
False extend [

jsonWriteOn: aStream [
<category: '*JSON-writing'>
aStream nextPutAll: 'false'
]

]

9 changes: 9 additions & 0 deletions Extensions/Integer.st
@@ -0,0 +1,9 @@
Integer extend [

jsonWriteOn: aWriteStream [
<category: '*JSON-writing'>
^self printOn: aWriteStream base: 10
]

]

9 changes: 9 additions & 0 deletions Extensions/Number.st
@@ -0,0 +1,9 @@
Number extend [

jsonWriteOn: aWriteStream [
<category: '*JSON-writing'>
self printOn: aWriteStream base: 10
]

]

9 changes: 9 additions & 0 deletions Extensions/Object.st
@@ -0,0 +1,9 @@
Object extend [

asJsonString [
<category: '*JSON'>
^String streamContents: [:str | self jsonWriteOn: str]
]

]

15 changes: 15 additions & 0 deletions Extensions/String.st
@@ -0,0 +1,15 @@
String extend [

jsonWriteOn: aStream [
<category: '*JSON-writing'>
| replacement |
aStream nextPut: $".
self do:
[:ch |
replacement := (Json escapeForCharacter: ch) asString.
aStream nextPutAll: replacement].
aStream nextPut: $"
]

]

9 changes: 9 additions & 0 deletions Extensions/Text.st
@@ -0,0 +1,9 @@
Text extend [

jsonWriteOn: aStream [
<category: '*json-printing'>
self string jsonWriteOn: aStream
]

]

9 changes: 9 additions & 0 deletions Extensions/True.st
@@ -0,0 +1,9 @@
True extend [

jsonWriteOn: aStream [
<category: '*JSON-writing'>
aStream nextPutAll: 'true'
]

]

9 changes: 9 additions & 0 deletions Extensions/UndefinedObject.st
@@ -0,0 +1,9 @@
UndefinedObject extend [

jsonWriteOn: aWriteStream [
<category: '*JSON-writing'>
aWriteStream nextPutAll: 'null'
]

]

9 changes: 9 additions & 0 deletions Extensions/WriteStream.st
@@ -0,0 +1,9 @@
WriteStream extend [

jsonPrint: anObject [
<category: '*json-printing'>
anObject jsonWriteOn: self
]

]

0 comments on commit e43dbc6

Please sign in to comment.