Examples of JsonParser


Examples of com.skaringa.json.parser.JsonParser

  public static void main(String args[]) throws Exception {
    ClassLoader classLoader = JsonParser.class.getClassLoader();

    String json = "{\"value\" : \"abcdef\\\"����\"}";
    StringReader reader = new StringReader(json);
    JsonParser parser = new JsonParser(reader, StringObj.class, classLoader);
    parser.process();
    System.out.println(parser.getObject().toString());

    json = "{\"value1\" : 10,\n\"value2\":-10E6}";
    reader = new StringReader(json);
    parser = new JsonParser(reader, null, classLoader);
    parser.process();
    System.out.println(parser.getObject());

    json = "{\"value\" : true}";
    reader = new StringReader(json);
    parser = new JsonParser(reader, BooleanObj.class, classLoader);
    parser.process();
    System.out.println(parser.getObject());

    json = "[\"alpha\",\"beta\",\"gamma\"]";
    reader = new StringReader(json);
    parser = new JsonParser(reader, null, classLoader);
    parser.process();
    System.out.println(parser.getObject());

    reader = new StringReader(json);
    parser = new JsonParser(reader, String[].class, classLoader);
    parser.process();
    System.out.println(Arrays.asList((String[]) parser.getObject()));

    json = "{\"myArray\":[{\"value\":\"0\"},{\"value\":\"1\"},{\"value\":\"2\"}]}";
    reader = new StringReader(json);
    parser = new JsonParser(reader, ComplexArrayObj.class, classLoader);
    parser.process();
    System.out.println(parser.getObject());
  }
View Full Code Here

Examples of com.voyagegames.core.json.JsonParser

  private JsonParser mParser;

  @Before
  public void setUp() throws Exception {
    log.logs.clear();
    mParser = new JsonParser(log);
  }
View Full Code Here

Examples of com.xmage.ws.util.json.JSONParser

*/
public class TestJSONParser {

    @Test
    public void testParse() throws Exception {
        JSONParser parser = new JSONParser();
        parser.parseJSON("{}");
        parser.parseJSON("{\"test\" : 1}");
        parser.parseJSON("{\"test\" : \"test\"}");
        parser.parseJSON("{\"list\" : [\"1\", \"2\", \"3\"]}");
        parser.parseJSON("{test:test}");

        testError(parser, "{");
        testError(parser, "}");
        testError(parser, "{{}");
        testError(parser, "{\"test\" : [}}");
View Full Code Here

Examples of gherkin.JSONParser

    }

    private void checkJson(String json) {
        Appendable io = new StringBuilder();
        JSONPrettyFormatter f = new JSONPrettyFormatter(io);
        JSONParser p = new JSONParser(f, f);
        p.parse(json);
        f.done();

        Gson gson = new Gson();

        List expected = gson.fromJson(new StringReader(json), List.class);
View Full Code Here

Examples of javax.json.stream.JsonParser

   @Test
   public void testJsonRead()
   {
      String jsonData = "{\"firstName\": \"George\", \"lastName\": \"Gastaldi\"}";
      JsonParser parser = Json.createParser(new StringReader(jsonData));
      Assert.assertTrue(parser.hasNext());
      Assert.assertEquals(Event.START_OBJECT, parser.next());
      Assert.assertTrue(parser.hasNext());
      Assert.assertEquals(Event.KEY_NAME, parser.next());
      Assert.assertEquals("firstName", parser.getString());
      Assert.assertTrue(parser.hasNext());
      Assert.assertEquals(Event.VALUE_STRING, parser.next());
      Assert.assertEquals("George", parser.getString());
      Assert.assertTrue(parser.hasNext());
      Assert.assertEquals(Event.KEY_NAME, parser.next());
      Assert.assertEquals("lastName", parser.getString());
      Assert.assertTrue(parser.hasNext());
      Assert.assertEquals(Event.VALUE_STRING, parser.next());
      Assert.assertEquals("Gastaldi", parser.getString());
      Assert.assertTrue(parser.hasNext());
      Assert.assertEquals(Event.END_OBJECT, parser.next());
      Assert.assertFalse(parser.hasNext());
   }
View Full Code Here

Examples of jsonij.json.JSONParser

                                c = (char) target.read();
                                expressionStringBuilder.append(c);
                                predicateComponentBuilder.append(c);
                            }
                            value = predicateComponentBuilder.toString().trim();
                            JSONParser jsonParser = new JSONParser();
                            Value jsonValue = jsonParser.parseValue(value);
                            target.skipWhitepace(expressionStringBuilder);
                            OperatorExpressionPredicateCondition predicateCondition = new OperatorExpressionPredicateCondition(attribute, expressionPredicateOperator, jsonValue);
                            if(op != null) {
                                predicateCondition.setCombine(op);
                                op = null;
View Full Code Here

Examples of net.minecraft.util.com.google.gson.JsonParser

        this.g = false;
        return hashset;
    }

    public Map a(String s) {
        JsonElement jsonelement = (new JsonParser()).parse(s);

        if (!jsonelement.isJsonObject()) {
            return Maps.newHashMap();
        } else {
            JsonObject jsonobject = jsonelement.getAsJsonObject();
View Full Code Here

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

Examples of net.sourceforge.htmlunit.corejs.javascript.json.JsonParser

        }
    }

    private static Object parse(Context cx, Scriptable scope, String jtext) {
      try {
        return new JsonParser(cx, scope).parseValue(jtext);
      } catch (JsonParser.ParseException ex) {
        throw ScriptRuntime.constructError("SyntaxError", ex.getMessage());
      }
    }
View Full Code Here

Examples of org.apache.chemistry.opencmis.commons.impl.json.parser.JSONParser

     * Converts an error message or a HTTP status code into an Exception.
     */
    protected CmisBaseException convertStatusCode(int code, String message, String errorContent, Throwable t) {
        Object obj = null;
        try {
            JSONParser parser = new JSONParser();
            obj = parser.parse(errorContent);
        } catch (Exception pe) {
        }

        if (obj instanceof JSONObject) {
            JSONObject json = (JSONObject) obj;
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.