Package org.json

Examples of org.json.JSONTokener


    this.readModelParsers.put(modelIdentifier.getName(), parser);
    return parser;
  }
 
  private JSONObject loadContext(ContextIdentifier id) throws IOException {
    JSONTokener token = new JSONTokener(id.getLocation().openStream());
    JSONObject obj = new JSONObject(token);
    this.contextCache.put(id.getName(), obj);
    return obj;
  }
View Full Code Here


      }
    }
  }

  public static void createSequenceFileFromJSON(InputStream stream, String fileName) throws IOException {
    JSONTokener tokener = new JSONTokener(new InputStreamReader(stream, "UTF-8"));
    String outputFileName = outputPath + File.separator +fileName.substring(0, fileName.lastIndexOf(".")) + ".seq";
    Path outputPath = new Path(outputFileName);
    SequenceFile.Writer writer = null;
    if(useKey)
    {
View Full Code Here

      }
    }
  }

  public static void createSequenceFileFromJSON(FSDataInputStream fsDataInputStream, FSDataOutputStream fsDataOutputStream) throws IOException {
    JSONTokener tokener = new JSONTokener(new InputStreamReader(fsDataInputStream, "UTF-8"));
    PrintWriter pw = new PrintWriter(fsDataOutputStream);
    pw.println("[");
    tokener.nextClean();
    char tmp = '[';
    while(tmp != ']') {
      JSONObject obj = (JSONObject) tokener.nextValue();
      processJSONObject(obj);
      pw.println(obj.toString(4));
      tmp = tokener.nextClean();
      if (tmp != ']') {
        pw.println(",");
      }
    }
    pw.println("]");
View Full Code Here

 
  private void initializeWriter(R2RMLMappingIdentifier id, ContextIdentifier contextId, List<KR2RMLRDFWriter> writers) {
    JSONObject contextObj = new JSONObject();
    if (contextId != null) {
      try {
        JSONTokener token = new JSONTokener(contextId.getLocation().openStream());
        contextObj = new JSONObject(token);
      }catch(Exception e)
      {
       
      }
View Full Code Here

    }
    return result;
  }

  public static Object createJson(String jsonString) {
    Object result = createJSONObject(new JSONTokener(jsonString));
    if (result == null) {
      result = createJSONArray(new JSONTokener(jsonString));
    }
    if (result == null) {
      logger.error("Could not parse as JSONObject or JSONArray");
    }
    return result;
View Full Code Here

    }
    else if (json != null && json instanceof FileObject) {
      FileObject fo = (FileObject)json;
      boolean flag = true;
      try {
        JSONTokener tokener = new JSONTokener(new InputStreamReader(new FileInputStream(fo.file), fo.encoding));
        char c = tokener.nextClean();     
        if (c == '{') {
          getWorksheet().getMetadataContainer().getWorksheetProperties().setWorksheetDataStructure(DataStructure.OBJECT);
          JsonImportValues JsonImportValues = new JsonImportValues(maxNumLines, numObjects, getFactory(), getWorksheet(), columnsJson);
          JsonImportValues.addKeysAndValues(tokener, getWorksheet().getHeaders(),
              getWorksheet().getDataTable());
View Full Code Here

                                        String cs = HttpUtils.getCharset(media);
                                        if (cs == null) {
                                            cs = Charset.defaultCharset().name();
                                        }
                                        InputStreamReader reader = new InputStreamReader(content, cs);
                                        JSONTokener jt = new JSONTokener(reader);
                                        Processor processor = runtime.getProcessor();
                                        String flavor = runtime.jsonFlavor();
                                        documents.add(JSONtoXML.convert(processor, jt, flavor));
                                    }
                                });
View Full Code Here

        if (charset == null) {
            // FIXME: Is this right? I think it is...
            charset = "UTF-8";
        }
        InputStreamReader reader = new InputStreamReader(stream, charset);
        JSONTokener jt = new JSONTokener(reader);
        XdmNode jsonDoc = JSONtoXML.convert(runtime.getProcessor(), jt, runtime.jsonFlavor());
        tree.addSubtree(jsonDoc);
    } else {
        tree.addStartElement(wrapper);
        if (XProcConstants.c_data.equals(wrapper)) {
View Full Code Here

                tree.addText(s);
                len = reader.read(buf, 0, bufSize);
            }
        } else if (jsonContentType(contentType)) {
            InputStreamReader reader = new InputStreamReader(bodyStream);
            JSONTokener jt = new JSONTokener(reader);
            XdmNode jsonDoc = JSONtoXML.convert(runtime.getProcessor(), jt, runtime.jsonFlavor());
            tree.addSubtree(jsonDoc);
        } else {
            // Read it as binary
            byte bytes[] = new byte[bufSize];
View Full Code Here

                tree.addSubtree(tagDoc);
            } else {
                remapDefaultNamespace(tree, tagDoc);
            }
        } else if ("application/json".equals(contentType) || "text/json".equals(contentType)) {
            JSONTokener jt = new JSONTokener(escapedContent);
            XdmNode jsonDoc = JSONtoXML.convert(runtime.getProcessor(), jt, runtime.jsonFlavor());
            tree.addSubtree(jsonDoc);
        } else if (!"application/xml".equals(contentType)) {
            throw XProcException.stepError(51);
        } else {
View Full Code Here

TOP

Related Classes of org.json.JSONTokener

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.