src/jdk/nashorn/internal/runtime/JSONFunctions.java

changeset 1020
9ee8fd4a7266
parent 963
e2497b11a021
child 1205
4112748288bb
child 1228
3f7e205c2c44
equal deleted inserted replaced
1019:73c31575a0c0 1020:9ee8fd4a7266
120 final Object newElement = walk(valueObj, key, reviver); 120 final Object newElement = walk(valueObj, key, reviver);
121 121
122 if (newElement == ScriptRuntime.UNDEFINED) { 122 if (newElement == ScriptRuntime.UNDEFINED) {
123 valueObj.delete(key, false); 123 valueObj.delete(key, false);
124 } else { 124 } else {
125 setPropertyValue(valueObj, key, newElement, false); 125 setPropertyValue(valueObj, key, newElement);
126 } 126 }
127 } 127 }
128 } 128 }
129 129
130 try { 130 try {
177 for (final PropertyNode pNode: objNode.getElements()) { 177 for (final PropertyNode pNode: objNode.getElements()) {
178 final Node valueNode = pNode.getValue(); 178 final Node valueNode = pNode.getValue();
179 179
180 final String name = pNode.getKeyName(); 180 final String name = pNode.getKeyName();
181 final Object value = convertNode(global, valueNode); 181 final Object value = convertNode(global, valueNode);
182 setPropertyValue(object, name, value, false); 182 setPropertyValue(object, name, value);
183 } 183 }
184 184
185 return object; 185 return object;
186 } else if (node instanceof UnaryNode) { 186 } else if (node instanceof UnaryNode) {
187 // UnaryNode used only to represent negative number JSON value 187 // UnaryNode used only to represent negative number JSON value
191 return null; 191 return null;
192 } 192 }
193 } 193 }
194 194
195 // add a new property if does not exist already, or else set old property 195 // add a new property if does not exist already, or else set old property
196 private static void setPropertyValue(final ScriptObject sobj, final String name, final Object value, final boolean strict) { 196 private static void setPropertyValue(final ScriptObject sobj, final String name, final Object value) {
197 final int index = ArrayIndex.getArrayIndex(name); 197 final int index = ArrayIndex.getArrayIndex(name);
198 if (ArrayIndex.isValidArrayIndex(index)) { 198 if (ArrayIndex.isValidArrayIndex(index)) {
199 // array index key 199 // array index key
200 sobj.defineOwnProperty(index, value); 200 sobj.defineOwnProperty(index, value);
201 } else if (sobj.getMap().findProperty(name) != null) { 201 } else if (sobj.getMap().findProperty(name) != null) {
202 // pre-existing non-inherited property, call set 202 // pre-existing non-inherited property, call set
203 sobj.set(name, value, strict); 203 sobj.set(name, value, 0);
204 } else { 204 } else {
205 // add new property 205 // add new property
206 sobj.addOwnProperty(name, Property.WRITABLE_ENUMERABLE_CONFIGURABLE, value); 206 sobj.addOwnProperty(name, Property.WRITABLE_ENUMERABLE_CONFIGURABLE, value);
207 } 207 }
208 } 208 }

mercurial