Skip to content

Commit 21f3e0b

Browse files
committed
Updated to work with M4 0.5.0+1.r21823
1 parent c294685 commit 21f3e0b

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

lib/json_object.dart

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,24 +137,25 @@ class JsonObject<E> extends Object implements Map, Iterable {
137137
int positionalArgs = 0;
138138
if (mirror.positionalArguments != null) positionalArgs = mirror.positionalArguments.length;
139139

140+
var property = _symbolToString(mirror.memberName);
141+
140142
if (mirror.isGetter && (positionalArgs == 0)) {
141143
//synthetic getter
142-
var property = mirror.memberName;
143144
if (this.containsKey(property)) {
144145
return this[property];
145146
}
146147
}
147148
else if (mirror.isSetter && positionalArgs == 1) {
148149
//synthetic setter
149-
var property = mirror.memberName.replaceAll("=", "");
150150
//if the property doesn't exist, it will only be added
151151
//if isExtendable = true
152+
property = property.replaceAll("=", "");
152153
this[property] = mirror.positionalArguments[0]; // args[0];
153154
return this[property];
154155
}
155156

156157
//if we get here, then we've not found it - throw.
157-
_log("Not found: ${mirror.memberName}");
158+
_log("Not found: ${property}");
158159
_log("IsGetter: ${mirror.isGetter}");
159160
_log("IsSetter: ${mirror.isGetter}");
160161
_log("isAccessor: ${mirror.isAccessor}");
@@ -209,6 +210,15 @@ class JsonObject<E> extends Object implements Map, Iterable {
209210

210211
}
211212

213+
String _symbolToString(value) {
214+
if (value is Symbol) {
215+
return mirrors.MirrorSystem.getName(value);
216+
}
217+
else {
218+
return value.toString();
219+
}
220+
}
221+
212222
/***************************************************************************
213223
* Iterable implementation methods and properties *
214224
*/
@@ -284,7 +294,9 @@ class JsonObject<E> extends Object implements Map, Iterable {
284294
bool containsValue(value) => _objectData.containsValue(value);
285295

286296
// Pass through to the inner _objectData map.
287-
bool containsKey(value) => _objectData.containsKey(value);
297+
bool containsKey(value) {
298+
return _objectData.containsKey(_symbolToString(value));
299+
}
288300

289301
// Pass through to the inner _objectData map.
290302
operator [](key) => _objectData[key];

pubspec.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
name: json_object
2-
version: 1.0.14
2+
version: 0.5.0+1
33
author: Chris Buckett <chrisbuckett@gmail.com>
44
description: Allow use of JSON Maps in dot notation format
55
homepage: https://github.com/chrisbu/dartwatch-JsonObject
6+
environment:
7+
sdk: 0.5.0+1.r21823
68
dependencies:
7-
unittest: any
8-
meta: any
9+
meta: '>=0.5.0+1 <0.6.0'
10+
dev_dependencies:
11+
unittest: '>=0.5.0+1 <0.6.0'

0 commit comments

Comments
 (0)