Permalink
Browse files

replace JsonObject with Dictionary

  • Loading branch information...
lm committed Feb 16, 2012
1 parent 2bdae3e commit 43c2af0f8ccd4d49a5defb322483316c628baefa
Showing with 5 additions and 118 deletions.
  1. +1 −1 JSON/Json.st
  2. +0 −111 JSON/JsonObject.st
  3. +4 −4 JSON/JsonTests.st
  4. +0 −2 package.xml
View
@@ -145,7 +145,7 @@ Object subclass: Json [
readDictionary [
<category: 'private'>
| m k v needComma |
- m := JsonObject new.
+ m := Dictionary new.
needComma := false.
[self skipWhitespace.
View
@@ -1,111 +0,0 @@
-Object subclass: JsonObject [
- | dictionary |
-
- <category: 'JSON'>
- <comment: nil>
-
- JsonObject class >> fromAssociations: collectionOfAssociations [
- | result |
- result := Dictionary new.
- collectionOfAssociations do: [:each | result at: each key put: each value].
- ^(self new)
- dictionary: result;
- yourself
- ]
-
- at: aKey [
- "make it work more like javascript objects"
-
- <category: 'accessing'>
- ^self at: aKey ifAbsent: [nil]
- ]
-
- dictionary [
- <category: 'accessing'>
- dictionary ifNil: [dictionary := Dictionary new].
- ^dictionary
- ]
-
- dictionary: aDictionary [
- <category: 'accessing'>
- aDictionary ifNotNil: [:foo | dictionary := aDictionary]
- ]
-
- = aJsonObject [
- <category: 'overrides-to-dictionary'>
- ^aJsonObject dictionary = self dictionary
- ]
-
- at: aKey put: aValue [
- "override cause object defines this"
-
- <category: 'overrides-to-dictionary'>
- ^self dictionary at: aKey put: aValue
- ]
-
- bindingOf: varName [
- <category: 'overrides-to-dictionary'>
- ^self dictionary bindingOf: varName
- ]
-
- flattenOnStream: aStream [
- <category: 'overrides-to-dictionary'>
- ^self dictionary flattenOnStream: aStream
- ]
-
- isDictionary [
- <category: 'overrides-to-dictionary'>
- ^true
- ]
-
- javascriptOn: aStream [
- <category: 'overrides-to-dictionary'>
- self dictionary javascriptOn: aStream
- ]
-
- jsonOn: aStream [
- <category: 'overrides-to-dictionary'>
- self dictionary jsonOn: aStream
- ]
-
- name [
- "override 'cause Object defines this"
-
- <category: 'overrides-to-dictionary'>
- ^self at: 'name'
- ]
-
- storeOn: aStream [
- <category: 'overrides-to-dictionary'>
- ^self dictionary storeOn: aStream
- ]
-
- value [
- "override 'cause Object defines this"
-
- <category: 'overrides-to-dictionary'>
- ^self at: 'value'
- ]
-
- doesNotUnderstand: aMessage [
- | key result |
-
- [result := aMessage sendTo: self dictionary.
- ^result]
- on: MessageNotUnderstood
- do:
- [key := aMessage selector.
- key isUnary ifTrue: [^self at: key].
- ^(key isKeyword and: [(key occurrencesOf: $:) = 1])
- ifTrue:
- [key := key allButLast asSymbol.
- self dictionary at: key put: aMessage arguments first]
- ifFalse: [super doesNotUnderstand: aMessage]]
- ]
-
- initialize [
- super initialize.
- dictionary := Dictionary new
- ]
-]
-
View
@@ -90,17 +90,17 @@ TestCase subclass: JsonTests [
]
testDictionary [
- self json: '{}' equals: JsonObject new.
+ self json: '{}' equals: Dictionary new.
self json: '{"a": "a"}'
- equals: ((JsonObject new)
+ equals: ((Dictionary new)
at: 'a' put: 'a';
yourself).
self json: '{"a": [[]]}'
- equals: ((JsonObject new)
+ equals: ((Dictionary new)
at: 'a' put: #(#());
yourself).
self json: '{"a":"b", "b":"a"}'
- equals: ((JsonObject new)
+ equals: ((Dictionary new)
add: 'a' -> 'b';
add: 'b' -> 'a';
yourself)
View
@@ -13,7 +13,6 @@
<filein>Extensions/Integer.st</filein>
<filein>JSON/Json.st</filein>
<filein>JSON/JsonDummyTestObject.st</filein>
-<filein>JSON/JsonObject.st</filein>
<filein>JSON/JsonSyntaxError.st</filein>
<filein>Extensions/Number.st</filein>
<filein>Extensions/Object.st</filein>
@@ -28,7 +27,6 @@
<file>Extensions/Integer.st</file>
<file>JSON/Json.st</file>
<file>JSON/JsonDummyTestObject.st</file>
-<file>JSON/JsonObject.st</file>
<file>JSON/JsonSyntaxError.st</file>
<file>JSON/JsonTests.st</file>
<file>Extensions/Number.st</file>

0 comments on commit 43c2af0

Please sign in to comment.