Package se.llbit.json

Examples of se.llbit.json.JsonParser$SyntaxError


   * Parse the scene description from a JSON file.
   * @param in input stream - will be closed
   */
  public void loadDescription(InputStream in) throws IOException {
    try {
      JsonParser parser = new JsonParser(in);
      JsonObject desc = parser.parse().object();
      fromJson(desc);
    } catch (SyntaxError e) {
      throw new IOException("JSON syntax error");
    } finally {
      in.close();
View Full Code Here


    }

    // check version
    try {
      FileInputStream in = new FileInputStream(versionFile);
      JsonParser parser = new JsonParser(in);
      JsonObject obj = parser.parse().object();
      in.close();
      String versionName = obj.get("name").stringValue("");
      if (!versionName.equals(version)) {
        System.err.println("Stored version name does not match file name");
        return false;
View Full Code Here

    for (File versionFile: versionsDir.listFiles()) {
      if (versionFile.getName().endsWith(".json")) {
        try {
          FileInputStream in = new FileInputStream(versionFile);
          JsonParser parser = new JsonParser(in);
          versions.add(new VersionInfo(parser.parse().object()));
          in.close();
        } catch (IOException e) {
          System.err.println("Could not read version info file: " + e.getMessage());
        } catch (SyntaxError e) {
          System.err.println("Corrupted version info file: " + e.getMessage());
View Full Code Here

    try {
      ClassLoader parentCL = ChunkyLauncher.class.getClassLoader();
      InputStream in = parentCL.getResourceAsStream("version.json");
      try {
        if (in != null) {
          JsonParser parser = new JsonParser(in);
          return new VersionInfo(parser.parse().object());
        }
      } catch (IOException e) {
      } catch (SyntaxError e) {
      } finally {
        if (in != null) {
View Full Code Here

  }

  private VersionInfo getVersion(String url) throws IOException, SyntaxError {
    URL latestJson = new URL(url);
    InputStream in = latestJson.openStream();
    JsonParser parser = new JsonParser(in);
    VersionInfo version = new VersionInfo(parser.parse().object());
    in.close();
    return version;
  }
View Full Code Here

  }

  private static JsonObject readSceneJson(File file) throws IOException, SyntaxError {
    FileInputStream in = new FileInputStream(file);
    try {
      JsonParser parser = new JsonParser(in);
      return parser.parse().object();
    } finally {
      in.close();
    }
  }
View Full Code Here

    colorEdit.getDocument().addDocumentListener(documentListener);
  }

  @Override
  public void onTextInput(String data) {
    JsonParser parser = new JsonParser(new ByteArrayInputStream(data.getBytes()));
    try {
      List<Vector4d> newGradient = Sky.gradientFromJson(parser.parse().array());
      if (newGradient != null) {
        gradientUI.setGradient(newGradient);
      }
    } catch (IOException e) {
    } catch (SyntaxError e) {
View Full Code Here

   */
  public void load(File file) {
    String path = file.getAbsolutePath();
    try {
      InputStream in = new FileInputStream(file);
      JsonParser parser = new JsonParser(in);
      json = parser.parse().object();
      in.close();
      if (System.getProperty("log4j.logLevel", "WARN").equals("INFO")) {
        System.out.println("Settings loaded from " + path);
      }
    } catch (IOException e) {
View Full Code Here

        }
        String releaseTime = "";
        try {
          File jsonFile = new File(dirs[i], dirs[i].getName() + ".json");
          FileInputStream in = new FileInputStream(jsonFile);
          JsonParser parser = new JsonParser(in);
          JsonObject obj = parser.parse().object();
          releaseTime =  obj.get("releaseTime").stringValue("");
        } catch (IOException e) {
          // Json parsing failed
        } catch (SyntaxError e) {
          // Json parsing failed
View Full Code Here

TOP

Related Classes of se.llbit.json.JsonParser$SyntaxError

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.