Java Code Examples for jdk.nashorn.internal.parser.JSONParser#parse()
The following examples show how to use
jdk.nashorn.internal.parser.JSONParser#parse() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JSONFunctions.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Parses the given JSON text string and returns object representation. * * @param text JSON text to be parsed * @param reviver optional value: function that takes two parameters (key, value) * @return Object representation of JSON text given */ public static Object parse(final Object text, final Object reviver) { final String str = JSType.toString(text); final Global global = Context.getGlobal(); final boolean dualFields = ((ScriptObject) global).useDualFields(); final JSONParser parser = new JSONParser(str, global, dualFields); final Object value; try { value = parser.parse(); } catch (final ParserException e) { throw ECMAErrors.syntaxError(e, "invalid.json", e.getMessage()); } return applyReviver(global, value, reviver); }
Example 2
Source File: JSONFunctions.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Parses the given JSON text string and returns object representation. * * @param text JSON text to be parsed * @param reviver optional value: function that takes two parameters (key, value) * @return Object representation of JSON text given */ public static Object parse(final Object text, final Object reviver) { final String str = JSType.toString(text); final Global global = Context.getGlobal(); final boolean dualFields = ((ScriptObject) global).useDualFields(); final JSONParser parser = new JSONParser(str, global, dualFields); final Object value; try { value = parser.parse(); } catch (final ParserException e) { throw ECMAErrors.syntaxError(e, "invalid.json", e.getMessage()); } return applyReviver(global, value, reviver); }
Example 3
Source File: JSONFunctions.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Parses the given JSON text string and returns object representation. * * @param text JSON text to be parsed * @param reviver optional value: function that takes two parameters (key, value) * @return Object representation of JSON text given */ public static Object parse(final Object text, final Object reviver) { final String str = JSType.toString(text); final Global global = Context.getGlobal(); final boolean dualFields = ((ScriptObject) global).useDualFields(); final JSONParser parser = new JSONParser(str, global, dualFields); final Object value; try { value = parser.parse(); } catch (final ParserException e) { throw ECMAErrors.syntaxError(e, "invalid.json", e.getMessage()); } return applyReviver(global, value, reviver); }
Example 4
Source File: JSONFunctions.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Parses the given JSON text string and returns object representation. * * @param text JSON text to be parsed * @param reviver optional value: function that takes two parameters (key, value) * @return Object representation of JSON text given */ public static Object parse(final Object text, final Object reviver) { final String str = JSType.toString(text); final Global global = Context.getGlobal(); final boolean dualFields = ((ScriptObject) global).useDualFields(); final JSONParser parser = new JSONParser(str, global, dualFields); final Object value; try { value = parser.parse(); } catch (final ParserException e) { throw ECMAErrors.syntaxError(e, "invalid.json", e.getMessage()); } return applyReviver(global, value, reviver); }
Example 5
Source File: JSONFunctions.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Parses the given JSON text string and returns object representation. * * @param text JSON text to be parsed * @param reviver optional value: function that takes two parameters (key, value) * @return Object representation of JSON text given */ public static Object parse(final Object text, final Object reviver) { final String str = JSType.toString(text); final Global global = Context.getGlobal(); final boolean dualFields = ((ScriptObject) global).useDualFields(); final JSONParser parser = new JSONParser(str, global, dualFields); final Object value; try { value = parser.parse(); } catch (final ParserException e) { throw ECMAErrors.syntaxError(e, "invalid.json", e.getMessage()); } return applyReviver(global, value, reviver); }
Example 6
Source File: JSONFunctions.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Parses the given JSON text string and returns object representation. * * @param text JSON text to be parsed * @param reviver optional value: function that takes two parameters (key, value) * @return Object representation of JSON text given */ public static Object parse(final Object text, final Object reviver) { final String str = JSType.toString(text); final JSONParser parser = new JSONParser( new Source("<json>", str), new Context.ThrowErrorManager()); Node node; try { node = parser.parse(); } catch (final ParserException e) { throw ECMAErrors.syntaxError(e, "invalid.json", e.getMessage()); } final ScriptObject global = Context.getGlobalTrusted(); Object unfiltered = convertNode(global, node); return applyReviver(global, unfiltered, reviver); }
Example 7
Source File: JSONFunctions.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Parses the given JSON text string and returns object representation. * * @param text JSON text to be parsed * @param reviver optional value: function that takes two parameters (key, value) * @return Object representation of JSON text given */ public static Object parse(final Object text, final Object reviver) { final String str = JSType.toString(text); final JSONParser parser = new JSONParser( new Source("<json>", str), new Context.ThrowErrorManager()); Node node; try { node = parser.parse(); } catch (final ParserException e) { throw ECMAErrors.syntaxError(e, "invalid.json", e.getMessage()); } final ScriptObject global = Context.getGlobalTrusted(); Object unfiltered = convertNode(global, node); return applyReviver(global, unfiltered, reviver); }
Example 8
Source File: JSONFunctions.java From jdk8u_nashorn with GNU General Public License v2.0 | 6 votes |
/** * Parses the given JSON text string and returns object representation. * * @param text JSON text to be parsed * @param reviver optional value: function that takes two parameters (key, value) * @return Object representation of JSON text given */ public static Object parse(final Object text, final Object reviver) { final String str = JSType.toString(text); final Global global = Context.getGlobal(); final boolean dualFields = ((ScriptObject) global).useDualFields(); final JSONParser parser = new JSONParser(str, global, dualFields); final Object value; try { value = parser.parse(); } catch (final ParserException e) { throw ECMAErrors.syntaxError(e, "invalid.json", e.getMessage()); } return applyReviver(global, value, reviver); }
Example 9
Source File: JSONFunctions.java From nashorn with GNU General Public License v2.0 | 6 votes |
/** * Parses the given JSON text string and returns object representation. * * @param text JSON text to be parsed * @param reviver optional value: function that takes two parameters (key, value) * @return Object representation of JSON text given */ public static Object parse(final Object text, final Object reviver) { final String str = JSType.toString(text); final JSONParser parser = new JSONParser( new Source("<json>", str), new Context.ThrowErrorManager()); Node node; try { node = parser.parse(); } catch (final ParserException e) { throw ECMAErrors.syntaxError(e, "invalid.json", e.getMessage()); } final ScriptObject global = Context.getGlobalTrusted(); Object unfiltered = convertNode(global, node); return applyReviver(global, unfiltered, reviver); }
Example 10
Source File: JSONFunctions.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Parses the given JSON text string and returns object representation. * * @param text JSON text to be parsed * @param reviver optional value: function that takes two parameters (key, value) * @return Object representation of JSON text given */ public static Object parse(final Object text, final Object reviver) { final String str = JSType.toString(text); final Global global = Context.getGlobal(); final boolean dualFields = ((ScriptObject) global).useDualFields(); final JSONParser parser = new JSONParser(str, global, dualFields); final Object value; try { value = parser.parse(); } catch (final ParserException e) { throw ECMAErrors.syntaxError(e, "invalid.json", e.getMessage()); } return applyReviver(global, value, reviver); }