@@ -238,7 +238,7 @@ private static boolean parse(XMLTokener x, JSONObject context, String name)
238238 throw x .syntaxError ("Missing value" );
239239 }
240240 jsonobject .accumulate (string ,
241- XML .stringToValue ((String ) token ));
241+ JSONObject .stringToValue ((String ) token ));
242242 token = null ;
243243 } else {
244244 jsonobject .accumulate (string , "" );
@@ -270,7 +270,7 @@ private static boolean parse(XMLTokener x, JSONObject context, String name)
270270 string = (String ) token ;
271271 if (string .length () > 0 ) {
272272 jsonobject .accumulate ("content" ,
273- XML .stringToValue (string ));
273+ JSONObject .stringToValue (string ));
274274 }
275275
276276 } else if (token == LT ) {
@@ -296,50 +296,6 @@ private static boolean parse(XMLTokener x, JSONObject context, String name)
296296 }
297297 }
298298
299- /**
300- * Try to convert a string into a number, boolean, or null. If the string
301- * can't be converted, return the string. This is much less ambitious than
302- * JSONObject.stringToValue, especially because it does not attempt to
303- * convert plus forms, octal forms, hex forms, or E forms lacking decimal
304- * points.
305- *
306- * @param string
307- * A String.
308- * @return A simple JSON value.
309- */
310- public static Object stringToValue (String string ) {
311- if ("true" .equalsIgnoreCase (string )) {
312- return Boolean .TRUE ;
313- }
314- if ("false" .equalsIgnoreCase (string )) {
315- return Boolean .FALSE ;
316- }
317- if ("null" .equalsIgnoreCase (string )) {
318- return JSONObject .NULL ;
319- }
320-
321- // If it might be a number, try converting it, first as a Long, and then
322- // as a Double. If that doesn't work, return the string.
323- try {
324- char initial = string .charAt (0 );
325- if (initial == '-' || (initial >= '0' && initial <= '9' )) {
326- Long value = new Long (string );
327- if (value .toString ().equals (string )) {
328- return value ;
329- }
330- }
331- } catch (Exception ignore ) {
332- try {
333- Double value = new Double (string );
334- if (value .toString ().equals (string )) {
335- return value ;
336- }
337- } catch (Exception ignoreAlso ) {
338- }
339- }
340- return string ;
341- }
342-
343299 /**
344300 * Convert a well-formed (but not necessarily valid) XML string into a
345301 * JSONObject. Some information may be lost in this transformation because
0 commit comments