Package net.minidev.json.parser

Examples of net.minidev.json.parser.JSONParser


            throw new UnsupportedOperationException(obj.getClass().getName() + " can not be converted to JSON");
        }
    }

    private JSONParser createParser() {
        return new JSONParser(parseMode);
    }
View Full Code Here


    public Mode getMode() {
        return mode;
    }

    private JSONParser createParser(){
        return new JSONParser(mode.intValue());
    }
View Full Code Here

    return parseJson(b.toString());
  }
  public static Vo parseJson(String json) {
    JSONObject o = null;
    try {
        JSONParser p = new JSONParser();
        o = (JSONObject)p.parse(json);   
    } catch (Exception e) { fail(e); }
    return (Vo)parseObject(o);
  }
View Full Code Here

  public JSONRPC2Parser(final boolean preserveOrder,
                  final boolean ignoreVersion,
                  final boolean parseNonStdAttributes) {
 
    // Numbers parsed as long/double, requires JSON Smart 1.0.9+
    parser = new JSONParser(JSONParser.MODE_JSON_SIMPLE);
   
    this.preserveOrder = preserveOrder;
    this.ignoreVersion = ignoreVersion;
    this.parseNonStdAttributes = parseNonStdAttributes;
  }
View Full Code Here

        }

        if ("application/json".equalsIgnoreCase(contentType)) {

          log.debug("Handling JSON content, parts is named {}");
          JSONParser p = new JSONParser(
              JSONParser.DEFAULT_PERMISSIVE_MODE);

          JSONObject object = p.parse(reader, JSONObject.class);
          log.debug("object: {}", object);

          if (object instanceof Map) {
            for (String key : object.keySet()) {
View Full Code Here

 
  public final Object decodeFromString (final String data)
  {
    try {
      Preconditions.checkNotNull (data);
      final JSONParser parser = new JSONParser (JSONParser.MODE_RFC4627 & ~JSONParser.USE_HI_PRECISION_FLOAT);
      final Object structure = parser.parse (data);
      return (structure);
    } catch (final ParseException exception) {
      throw (new IllegalArgumentException (exception.getMessage (), exception.getCause ()));
    }
  }
View Full Code Here

  @Override
  public void map(LongWritable arg0, Text arg1,
      OutputCollector<IntWritable, Text> out, Reporter reporter)
      throws IOException {

    JSONParser parser = new JSONParser(JSONParser.MODE_JSON_SIMPLE);
    JSONObject obj;
    try {
      String rec = arg1.toString();
      obj = (JSONObject) parser.parse(rec);

      short owner = ((Long) obj.get("owner")).shortValue();
      out.collect(new IntWritable(owner), new Text(rec));
      JSONArray mirrors = (JSONArray) obj.get("mirrors");
      for (int j = 0; j < mirrors.size(); j++) {
View Full Code Here

  public void reduce(IntWritable key, Iterator<Text> value,
      OutputCollector<Text, Text> out, Reporter reporter) throws IOException {
    int numVertices = 0;
    int numOwnVertices = 0;

    JSONParser parser = new JSONParser(JSONParser.MODE_JSON_SIMPLE);
    while (value.hasNext()) {
      Text vrecString = value.next();
      JSONObject obj;
      try {
        obj = (JSONObject) parser.parse(vrecString.toString());
        int owner = ((Long) obj.get("owner")).intValue();
        if (owner == key.get()) {
          numOwnVertices++;
          reporter.incrCounter(COUNTER.OWN_VERTICES, 1);
        }
View Full Code Here

    vrec.setMirrorsFromList(mirrorList, numProcs);
    vrec.setOwner((short) 2);
    vrec.setInEdges(3);
    vrec.setOutEdges(2);
    String s = vrec.toString();
    JSONParser parser = new JSONParser(JSONParser.MODE_JSON_SIMPLE);
    try {
      JSONObject obj = (JSONObject) parser.parse(s);
      // System.out.println(obj.toJSONString());
    } catch (ParseException e) {
      e.printStackTrace();
    }

    s = "{\"mirrors\":[0,1,2,3,4,5,6,7],\"inEdges\":212,\"gvid\":0,\"outEdges\":4,\"owner\":5,\"VertexData\":null}";
    try {
      JSONObject obj = (JSONObject) parser.parse(s);
      // System.out.println(obj.toJSONString());
    } catch (ParseException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
View Full Code Here

        this.flags = flags;
    }

    public Map getFlagsAsMap() {
        if (flags != null && !flags.isEmpty()) {
            JSONParser parser = new JSONParser();
            try {
                return (Map) parser.parse(flags);
            } catch (Exception ex) {
            }
        }
        return new HashMap();
    }
View Full Code Here

TOP

Related Classes of net.minidev.json.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.