elemental.json.Json.parse()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(151)

本文整理了Java中elemental.json.Json.parse()方法的一些代码示例,展示了Json.parse()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Json.parse()方法的具体详情如下:
包路径:elemental.json.Json
类名称:Json
方法名:parse

Json.parse介绍

暂无

代码示例

代码示例来源:origin: com.vaadin/vaadin-server

private void readObject(ObjectInputStream in)
    throws IOException, ClassNotFoundException {
  in.defaultReadObject();
  // Read String versions of JsonObjects and parse into JsonObjects as
  // JsonObject is not serializable
  diffStates = new HashMap<>();
  @SuppressWarnings("unchecked")
  Map<ClientConnector, String> stringDiffStates = (HashMap<ClientConnector, String>) in
      .readObject();
  diffStates = new HashMap<>(stringDiffStates.size() * 2);
  for (ClientConnector key : stringDiffStates.keySet()) {
    try {
      diffStates.put(key, Json.parse(stringDiffStates.get(key)));
    } catch (JsonException e) {
      throw new IOException(e);
    }
  }
}

代码示例来源:origin: com.vaadin/vaadin-server

private ScssCacheEntry loadPersistedScssCache(String scssFilename,
    ServletContext sc) throws IOException {
  String realFilename = sc.getRealPath(scssFilename);
  File scssCacheFile = getScssCacheFile(new File(realFilename));
  if (!scssCacheFile.exists()) {
    return null;
  }
  String jsonString = readFile(scssCacheFile, StandardCharsets.UTF_8);
  JsonObject entryJson = Json.parse(jsonString);
  String cacheVersion = entryJson.getString("version");
  if (!Version.getFullVersion().equals(cacheVersion)) {
    // Compiled for some other Vaadin version, discard cache
    scssCacheFile.delete();
    return null;
  }
  return new ScssCacheEntry(entryJson);
}

代码示例来源:origin: com.googlecode.gwtquery/gwtquery

public JsonBuilderHandler(String payload) throws Throwable {
 jsonObject = Json.parse(payload);
}

代码示例来源:origin: com.vaadin/flow-maven-plugin

bundleConfigurationJson = Json.parse(fileContents);
} catch (JsonException e) {
  throw new IllegalArgumentException(String.format(

代码示例来源:origin: com.vaadin/flow-server

private Optional<JsonObject> readBundleManifest(WebBrowser browser,
    VaadinService service) {
  try (InputStream bundleManifestStream = service
      .getResourceAsStream(FLOW_BUNDLE_MANIFEST, browser, null)) {
    if (bundleManifestStream == null) {
      throw new IllegalArgumentException(String.format(
          "Failed to find the bundle manifest file '%s' in the servlet context for '%s' browsers."
              + " If you are running a dev-mode servlet container in maven e.g. `jetty:run` change it to `jetty:run-exploded`."
              + " If you are not compiling frontend resources, include the 'vaadin-maven-plugin' in your build script."
              + " Otherwise, you can skip this error either by disabling production mode, or by setting the servlet parameter '%s=true'.",
          FLOW_BUNDLE_MANIFEST,
          browser.isEs6Supported() ? "ES6" : "ES5",
          Constants.USE_ORIGINAL_FRONTEND_RESOURCES));
    }
    return Optional.of(Json.parse(IOUtils.toString(bundleManifestStream,
        StandardCharsets.UTF_8)));
  } catch (IOException e) {
    throw new UncheckedIOException(String.format(
        "Failed to read bundle manifest file at context path '%s'",
        FLOW_BUNDLE_MANIFEST), e);
  }
}

代码示例来源:origin: com.vaadin/flow-maven-plugin

private String getPackageName(ArtifactData webJar, String nameSourceJarPath) {
  String fileContents;
  try {
    fileContents = IOUtils.toString(jarContentsManager.getFileContents(webJar.getFileOrDirectory(), nameSourceJarPath), StandardCharsets.UTF_8.displayName());
  } catch (IOException e) {
    throw new UncheckedIOException(String.format("Unable to read file '%s' from webJar '%s'", nameSourceJarPath, webJar.getFileOrDirectory()), e);
  }
  JsonObject jsonObject = Json.parse(fileContents);
  if (jsonObject.hasKey("name")) {
    String name = jsonObject.getString("name");
    return name.substring(name.lastIndexOf('/') + 1);
  } else {
    throw new IllegalStateException(String.format("Incorrect WebJar '%s': file '%s' inside it has no 'name' field", webJar, nameSourceJarPath));
  }
}

代码示例来源:origin: com.vaadin/license-checker

private static JsonObject queryServer(Product product, ProKey proKey)
    throws IOException {
  URL url = new URL(LICENSE_VALIDATION_URL);
  URLConnection http = url.openConnection();
  http.setRequestProperty("check-source", "java");
  http.setRequestProperty("product-name", product.getName());
  http.setRequestProperty("product-version", product.getVersion());
  for (String property : PROPERTIES) {
    String value = System.getProperty(property);
    if (value != null) {
      http.setRequestProperty("prop-" + property.replace(".", "-"),
          value);
    }
  }
  http.setRequestProperty("product-version", product.getVersion());
  http.setRequestProperty("Cookie", "proKey=" + proKey.getProKey());
  http.connect();
  try (InputStream in = http.getInputStream()) {
    String response = Util.toString(in);
    return Json.parse(response);
  }
}

代码示例来源:origin: com.vaadin/license-checker

public static ProKey fromJson(String jsonData) {
  JsonObject json = Json.parse(jsonData);
  ProKey proKey = new ProKey(json.getString("username"),
      json.getString("proKey"));
  return proKey;
}

代码示例来源:origin: org.eclipse.che.plugin/che-plugin-yaml-ide

/**
 * Converts json string to list of Yaml Preferences
 *
 * @param jsonStr The json string to turn into the list of Yaml Preferences
 * @return List of Yaml Preferences
 */
private List<YamlPreference> jsonToYamlPreference(String jsonStr) {
 ArrayList yamlPreferences = new ArrayList<YamlPreference>();
 JsonObject parsedJson = Json.parse(jsonStr);
 for (String glob : parsedJson.keys()) {
  try {
   JsonArray jsonArray = parsedJson.getArray(glob);
   for (int arrNum = 0; arrNum < jsonArray.length(); arrNum++) {
    YamlPreference newYamlPref = new YamlPreference(jsonArray.getString(arrNum), glob);
    yamlPreferences.add(newYamlPref);
   }
  } catch (Exception e) {
   LOG.debug(e.getMessage(), e);
  }
 }
 return yamlPreferences;
}

代码示例来源:origin: com.haulmont.cuba/cuba-web-widgets

@Override
public void beforeClientResponse(boolean initial) {
  super.beforeClientResponse(initial);
  if (initial || dirty) {
    if (stateData != null) {
      String json = getStateSerializer().toJson(stateData);
      getState().data = Json.parse(json);
    } else {
      getState().data = null;
    }
    dirty = false;
  }
}

代码示例来源:origin: com.googlecode.gwtquery/gwtquery

json = Properties.wrapPropertiesString(json);
 jsonObject = Json.parse(json);
} else if ("strip".equals(mname)) {
 stripProxy((JsonBuilder) proxy);

代码示例来源:origin: de.knightsoft-net/gwt-mt-widgets

Webshims.setOptions(Json.parse( //
  "{\n" //
    + "  \"forms-ext\": {\n" //

代码示例来源:origin: ManfredTremmel/gwt-bean-validators

Webshims.setOptions(Json.parse( //
  "{\n" //
    + "  \"forms-ext\": {\n" //

相关文章

微信公众号

最新文章

更多