当前位置: 首页>>代码示例>>Java>>正文


Java JSONParser类代码示例

本文整理汇总了Java中jdk.nashorn.internal.parser.JSONParser的典型用法代码示例。如果您正苦于以下问题:Java JSONParser类的具体用法?Java JSONParser怎么用?Java JSONParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JSONParser类属于jdk.nashorn.internal.parser包,在下文中一共展示了JSONParser类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parse

import jdk.nashorn.internal.parser.JSONParser; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:JSONFunctions.java

示例2: parse

import jdk.nashorn.internal.parser.JSONParser; //导入依赖的package包/类
/**
 * 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(sourceFor("<json>", str), new Context.ThrowErrorManager());

    Node node;

    try {
        node = parser.parse();
    } catch (final ParserException e) {
        throw ECMAErrors.syntaxError(e, "invalid.json", e.getMessage());
    }

    final Global global = Context.getGlobal();
    final Object unfiltered = convertNode(global, node);
    return applyReviver(global, unfiltered, reviver);
}
 
开发者ID:infobip,项目名称:infobip-open-jdk-8,代码行数:24,代码来源:JSONFunctions.java

示例3: parse

import jdk.nashorn.internal.parser.JSONParser; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:wro4j,项目名称:nashorn-backport,代码行数:26,代码来源:JSONFunctions.java

示例4: quote

import jdk.nashorn.internal.parser.JSONParser; //导入依赖的package包/类
private static String quote(final String str) {
    return JSONParser.quote(str);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:JSONWriter.java

示例5: quote

import jdk.nashorn.internal.parser.JSONParser; //导入依赖的package包/类
/**
 * Returns JSON-compatible quoted version of the given string.
 *
 * @param str String to be quoted
 * @return JSON-compatible quoted string
 */
public static String quote(final String str) {
    return JSONParser.quote(str);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:JSONFunctions.java


注:本文中的jdk.nashorn.internal.parser.JSONParser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。