[squeak-dev] The Trunk: JSON-matthias.berth.26.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Sep 8 14:57:44 UTC 2022


Christoph Thiede uploaded a new version of JSON to project The Trunk:
http://source.squeak.org/trunk/JSON-matthias.berth.26.mcz

==================== Summary ====================

Name: JSON-matthias.berth.26
Author: matthias.berth
Time: 19 November 2009, 6:03:27 pm
UUID: 7c715040-c8a1-485f-a5e8-6517ca2c3d56
Ancestors: JSON-tonyg.25

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: .

=============== Diff against JSON-tonyg.25 ===============

Item was added:
+ ----- Method: Association>>jsonWriteOn: (in category '*JSON-writing') -----
+ jsonWriteOn: aStream
+ 	self key asString jsonWriteOn: aStream.
+ 	aStream nextPut: $:; space.
+ 	self value jsonWriteOn: aStream.!

Item was added:
+ ----- Method: JsonTests>>testWriteAssociation (in category 'as yet unclassified') -----
+ testWriteAssociation
+ 	self render: 'key' -> 'value' equals: '"key": "value"'.
+ 	self render: 'key' -> 2 equals: '"key": 2'.
+ 	"keys should be strings"
+ 	self render: 42 -> 2 equals: '"42": 2'.
+ 	"try to do _something_ for more complex keys"
+ 	self render: #(42 43 44) -> 2 equals:  '"#(42 43 44)": 2'.
+ 	
+ 	
+ 	!



More information about the Squeak-dev mailing list