Package org.json.simple.parser

Examples of org.json.simple.parser.JSONParser


  @Override
  public void parse(MGraph target, InputStream serializedGraph, String formatIdentifier, UriRef baseUri) {

    BNodeManager bNodeMgr = new BNodeManager();

    JSONParser parser = new JSONParser();
    InputStreamReader reader;
    try {
      reader = new InputStreamReader(serializedGraph, "UTF-8");
    } catch (UnsupportedEncodingException e) {
      String msg = "Encoding 'UTF-8' is not supported by this System";
      logger.error("{} (message: {})", msg, e.getMessage());
      throw new IllegalStateException(msg, e);
    }

    try {
      JSONObject root = (JSONObject) parser.parse(reader);

      NonLiteral nonLiteral = null;
      for (Object key : root.keySet()) {
        String keyString = (String) key;
        if (keyString.startsWith("_:")) {
View Full Code Here


        Gson gson = new Gson();
        try
        {
            System.out.println(json);
            logger.error(gson);
            JSONParser jsonParser = new JSONParser();
            Object obj = jsonParser.parse(json);
            JSONObject jsonObject = (JSONObject) obj;
            json = (String) jsonObject.get("profile").toString();
            logger.info("JSON: " + json);
            SocialUser user = gson.fromJson(json,SocialUser.class);
            logger.info("guid: " + user.getGuid());
View Full Code Here

                + "\"full_name\":\"mmqx2219\""
                + "}"
             + "}";
       
        logger.info(accessTokenJson);
        JSONParser jsonParser = new JSONParser();
        try
        {
            Object obj = jsonParser.parse(accessTokenJson);
            JSONObject jsonObj = (JSONObject) obj;
            String accessToken = (String) jsonObj.get("access_token");
            logger.info("Access Token: " + accessToken);
            jsonObj = (JSONObject) jsonObj.get("user");
            String userName = (String) jsonObj.get("username");
View Full Code Here

      throw new RuntimeException("Failed to load JSON", e);
    }

    Object jsonValue;
    try {
      jsonValue = new JSONParser().parse(jsonModelData.getJsonText());
    } catch (ParseException e) {
      throw new RuntimeException("Failed to parse json", e);
    }

    WipMetamodelParser metaModelParser = WipMetamodelParser.Impl.get();
View Full Code Here

  private static List<WipTabList.TabDescription> parseJsonReponse(String content)
      throws IOException {
    Object jsonValue;
    try {
      jsonValue = new JSONParser().parse(content);
    } catch (ParseException e) {
      throw new IOException("Failed to parse a JSON tab list response", e);
    }

    try {
View Full Code Here

  private static List<WipTabList.TabDescription> parseJsonReponse(String content)
      throws IOException {
    Object jsonValue;
    try {
      jsonValue = new JSONParser().parse(content);
    } catch (ParseException e) {
      throw new IOException("Failed to parse a JSON tab list response", e);
    }

    try {
View Full Code Here

     *
     * @return a {@code JSONParser} instance
     */
    protected synchronized JSONParser getJSONParser() {
        if (parser == null) {
            parser = new JSONParser();
        }
        return parser;
    }
View Full Code Here

     * @param json string to be parsed
     * @return a {@code JSONObject}
     * @throws {@code AssertionError} if the string cannot be parsed into a {@code JSONObject}
     */
    protected JSONObject parseJSONObject(String json) throws AssertionError {
        JSONParser parser = getJSONParser();
        try {
            Object obj = parser.parse(json);
            assertTrue(obj instanceof JSONObject);
            return (JSONObject) obj;
        } catch (Exception e) {
            throw new AssertionError("not a valid JSON object: " + e.getMessage());
        }
View Full Code Here

     * @param json string to be parsed
     * @return a {@code JSONArray}
     * @throws {@code AssertionError} if the string cannot be parsed into a {@code JSONArray}
     */
    protected JSONArray parseJSONArray(String json) throws AssertionError {
        JSONParser parser = getJSONParser();
        try {
            Object obj = parser.parse(json);
            assertTrue(obj instanceof JSONArray);
            return (JSONArray) obj;
        } catch (Exception e) {
            throw new AssertionError("not a valid JSON array: " + e.getMessage());
        }
View Full Code Here

     * @param json string to be parsed
     * @return a {@code JSONArray}
     * @throws {@code AssertionError} if the string cannot be parsed into a {@code JSONArray}
     */
    private JSONArray parseJSONArray(String json) throws AssertionError {
        JSONParser parser = new JSONParser();
        try {
            Object obj = parser.parse(json);
            assertTrue(obj instanceof JSONArray);
            return (JSONArray) obj;
        } catch (Exception e) {
            throw new AssertionError("not a valid JSON array: " + e.getMessage());
        }
View Full Code Here

TOP

Related Classes of org.json.simple.parser.JSONParser

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.