Examples of JSONTokener


Examples of org.json.JSONTokener

                }
            } else if (this.jsonValue instanceof JSONStringer) {
                JSONStringer jsonStringer = (JSONStringer) this.jsonValue;
                result = jsonStringer.toString();
            } else if (this.jsonValue instanceof JSONTokener) {
                JSONTokener jsonTokener = (JSONTokener) this.jsonValue;
                result = jsonTokener.toString();
            }
        } else if (this.jsonRepresentation != null) {
            try {
                result = this.jsonRepresentation.getText();
            } catch (IOException e) {
View Full Code Here

Examples of org.json.JSONTokener

     * @throws JSONException
     * @deprecated Use {@link #getJsonTokener()} instead.
     */
    @Deprecated
    public JSONTokener toJsonTokener() throws JSONException {
        return new JSONTokener(getJsonText());
    }
View Full Code Here

Examples of org.json.JSONTokener

   */
  public static Token packetToToken(WebSocketPacket aDataPacket) {
    Token lToken = new Token();
    try {
      String lStr = aDataPacket.getString("UTF-8");
      JSONTokener lJSONTokener = new JSONTokener(lStr);
      lToken.setJSONObject(new JSONObject(lJSONTokener));
    } catch (UnsupportedEncodingException ex) {
      // TODO: handle exception
      // log.error(ex.getClass().getSimpleName() + ": " + ex.getMessage());
    } catch (JSONException ex) {
View Full Code Here

Examples of org.json.JSONTokener

     */
    public Widget getMetadata(String url) {
        Widget widget = new WidgetImpl();
        JSONObject jsonGadget = null;
        try {
            jsonGadget = (JSONObject) new JSONTokener(gadgetMetadataRepository.getGadgetMetadata(url)).nextValue();
            if (jsonGadget != null) {
                String query = jsonGadget.getString("modulePrefs");
                if (query != null) {
                    JSONObject jsonModulePrefsObject = (JSONObject) new JSONTokener(query).nextValue();
                    if (jsonModulePrefsObject != null) {
                        widget.setTitle(parseProperty(jsonModulePrefsObject, "title"));
                        widget.setTitleUrl(parseProperty(jsonModulePrefsObject, "titleUrl"));
                        widget.setDescription(parseProperty(jsonModulePrefsObject, "description"));
                        widget.setAuthor(parseProperty(jsonModulePrefsObject, "author"));
                        widget.setAuthorEmail(parseProperty(jsonModulePrefsObject, "authorEmail"));
                        widget.setThumbnailUrl(parseProperty(jsonModulePrefsObject, "thumbnail"));
                        widget.setScreenshotUrl(parseProperty(jsonModulePrefsObject, "screenshot"));
                        widget.setUrl(url);
                        widget.setType(getSupportedContext());
                    }
                }
            }
        } catch (JSONException e) {
            try {
                String query = jsonGadget.getString("error");
                if (query != null) {
                    JSONObject jsonModuleErrorObject = (JSONObject) new JSONTokener(query).nextValue();
                    if (jsonModuleErrorObject != null) {
                        String errorMessage = jsonModuleErrorObject.getString("message");
                        String errorCode = jsonModuleErrorObject.getString("code");
                        throw new IllegalArgumentException("HTTP error: " + errorCode + ". Message: " + errorMessage);
                    }
View Full Code Here

Examples of org.json.me.JSONTokener

    return contents;
  }

  public static JSONObject fromJSONFile(String filename) {
    try {
      return new JSONObject(new JSONTokener(getFileContents(filename)));
    } catch (JSONException e) {
      e.printStackTrace();
      return null;
    }
  }
View Full Code Here

Examples of org.openfaces.org.json.JSONTokener

            String text;
            do {
                text = bufferedReader.readLine();
            } while (text.startsWith("/*") || text.startsWith(" *") || text.trim().length() == 0);
            text = text.substring(1, text.length() - 1);
            JSONObject result = new JSONObject(new JSONTokener(text));
            return result;
        } finally {
            if (bufferedReader != null) {
                bufferedReader.close();
            }
View Full Code Here

Examples of org.richfaces.json.JSONTokener

      throw exception;
    }
  }
 
  private static void replace(FacesContext context, UIComponent effect, StringBuffer s) throws Exception {
    JSONTokener x = new JSONTokener(s.toString());
        char c;
        String key;

        if (x.nextClean() != '{') {
            throw x.syntaxError("A JSONObject text must begin with '{'");
        }
        for (;;) {
            int idx;
          c = x.nextClean();
            switch (c) {
            case 0:
                throw x.syntaxError("A JSONObject text must end with '}'");
            case '}':
                return;
            default:
                x.back();
              idx = x.getMyIndex();
              //System.out.println(s.substring(x.getMyIndex()));
                key = x.nextValue().toString();
            }

            /*
             * The key is followed by ':'. We will also tolerate '=' or '=>'.
             */

            c = x.nextClean();
            if (c == '=') {
                if (x.next() != '>') {
                    x.back();
                }
            } else if (c != ':') {
                throw x.syntaxError("Expected a ':' after a key");
            }
           
            if ("id".equals(key)) {
              Object value = x.nextValue();
        UIComponent component = RendererUtils.getInstance().findComponentFor(effect, value.toString());
        if (component != null) {
          value = component.getClientId(context);
        }

             
              s.replace(idx, x.getMyIndex(), "'id': '" + value + "'");
             
              return ;
            } else {
              x.nextValue();
            }

            /*
             * Pairs are separated by ','. We will also tolerate ';'.
             */

            switch (x.nextClean()) {
            case ';':
            case ',':
                if (x.nextClean() == '}') {
                    return;
                }
                x.back();
                break;
            case '}':
                return;
            default:
                throw x.syntaxError("Expected a ',' or '}'");
            }
        }
  } 
View Full Code Here

Examples of org.richfaces.json.JSONTokener

      throw exception;
    }
  }
 
  private static void replace(FacesContext context, UIComponent effect, StringBuffer s) throws Exception {
    JSONTokener x = new JSONTokener(s.toString());
        char c;
        String key;

        if (x.nextClean() != '{') {
            throw x.syntaxError("A JSONObject text must begin with '{'");
        }
        for (;;) {
            int idx;
          c = x.nextClean();
            switch (c) {
            case 0:
                throw x.syntaxError("A JSONObject text must end with '}'");
            case '}':
                return;
            default:
                x.back();
              idx = x.getMyIndex();
              //System.out.println(s.substring(x.getMyIndex()));
                key = x.nextValue().toString();
            }

            /*
             * The key is followed by ':'. We will also tolerate '=' or '=>'.
             */

            c = x.nextClean();
            if (c == '=') {
                if (x.next() != '>') {
                    x.back();
                }
            } else if (c != ':') {
                throw x.syntaxError("Expected a ':' after a key");
            }
           
            if ("id".equals(key)) {
              Object value = x.nextValue();
        UIComponent component = RendererUtils.getInstance().findComponentFor(effect, value.toString());
        if (component != null) {
          value = component.getClientId(context);
        }

             
              s.replace(idx, x.getMyIndex(), "'id': '" + value + "'");
             
              return ;
            } else {
              x.nextValue();
            }

            /*
             * Pairs are separated by ','. We will also tolerate ';'.
             */

            switch (x.nextClean()) {
            case ';':
            case ',':
                if (x.nextClean() == '}') {
                    return;
                }
                x.back();
                break;
            case '}':
                return;
            default:
                throw x.syntaxError("Expected a ',' or '}'");
            }
        }
  } 
View Full Code Here

Examples of org.rssowl.core.internal.interpreter.json.JSONTokener

    IModelFactory typesFactory = Owl.getModelFactory();
    IFeed feed = typesFactory.createFeed(null, link);
    feed.setBase(readerToHTTP(link));
    try {
      reader = new InputStreamReader(inS, UTF_8);
      JSONObject obj = new JSONObject(new JSONTokener(reader));
      Owl.getInterpreter().interpretJSONObject(obj, feed);
    } catch (JSONException e) {
      isError = true;
      throw new ParserException(Activator.getDefault().createErrorStatus(e.getMessage(), e));
    } catch (IOException e) {
View Full Code Here

Examples of restx.build.org.json.JSONTokener

        }
        public ModuleDescriptor parse(InputStream inputStream) throws IOException {
            return parse(null, inputStream);
        }
        private ModuleDescriptor parse(Path path, InputStream inputStream) throws IOException {
            JSONObject jsonObject = new JSONObject(new JSONTokener(new InputStreamReader(inputStream, "UTF-8")));

            Map<String, String> properties = new LinkedHashMap<>();
            if (jsonObject.has("properties")) {
                loadJsonProperties(path == null ? null : path.getParent(), properties, jsonObject.getJSONObject("properties"));
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.