Examples of parseJSON()


Examples of com.xmage.ws.util.json.JSONParser.parseJSON()

    }

    @Test
    public void testQueryForJSONArray() throws Exception {
        JSONParser parser = new JSONParser();
        parser.parseJSON("{\"test\" : [\"1\", \"2\", \"3\"]}");
        Assert.assertTrue(parser.getJSONArray("test") instanceof JSONArray);
        Assert.assertEquals("1", parser.getJSONArray("test").get(0));

        parser = new JSONParser();
        parser.parseJSON("{\"test\" : [1,2,3]}");
View Full Code Here

Examples of com.xmage.ws.util.json.JSONParser.parseJSON()

        parser.parseJSON("{\"test\" : [\"1\", \"2\", \"3\"]}");
        Assert.assertTrue(parser.getJSONArray("test") instanceof JSONArray);
        Assert.assertEquals("1", parser.getJSONArray("test").get(0));

        parser = new JSONParser();
        parser.parseJSON("{\"test\" : [1,2,3]}");
        Assert.assertTrue(parser.getJSONArray("test") instanceof JSONArray);
        Assert.assertFalse(parser.isHitCache());
        Assert.assertEquals(2, parser.getJSONArray("test").get(1));
        Assert.assertTrue(parser.isHitCache());
View Full Code Here

Examples of com.xmage.ws.util.json.JSONParser.parseJSON()

        Assert.assertTrue(parser.getJSONArray("test") instanceof JSONArray);
        Assert.assertEquals(2, parser.getJSONArray("test").get(1));
        Assert.assertTrue(parser.isHitCache());

        parser = new JSONParser();
        parser.parseJSON("{\"test\" : [{second_level: \"3\"}, {\"third_level\" : 2}]}");
        Assert.assertTrue(parser.getJSONArray("test") instanceof JSONArray);
        Assert.assertTrue(parser.getJSONArray("test").get(0) instanceof JSONObject);
        Assert.assertEquals(2, parser.getInt("test[1].third_level"));
        Assert.assertEquals("3", parser.getString("test[0].second_level"));
View Full Code Here

Examples of com.xmage.ws.util.json.JSONParser.parseJSON()

        Assert.assertTrue(parser.getJSONArray("test").get(0) instanceof JSONObject);
        Assert.assertEquals(2, parser.getInt("test[1].third_level"));
        Assert.assertEquals("3", parser.getString("test[0].second_level"));

        parser = new JSONParser();
        parser.parseJSON("{\"test\" : [{1:1},{1:1},{1:1},{1:1},{1:1},{1:1},{1:1},{1:1},{1:1},{2:3},{4:5}]}");
        Assert.assertTrue(parser.getJSONArray("test") instanceof JSONArray);
        Assert.assertEquals(5, parser.getInt("test[10].4"));
    }

    @Test
View Full Code Here

Examples of com.xmage.ws.util.json.JSONParser.parseJSON()

    }

    @Test
    public void testExtendedCache() throws Exception {
        JSONParser parser = new JSONParser();
        parser.parseJSON("{test : { internal : {level : 2}}}");
        Assert.assertEquals(2, parser.getInt("test.internal.level"));
        Assert.assertFalse("No cache should have been used", parser.isHitCache());

        Assert.assertTrue(parser.getJSON("test") instanceof JSONObject);
        Assert.assertFalse("No cache should have been used", parser.isHitCache());
View Full Code Here

Examples of com.xmage.ws.util.json.JSONParser.parseJSON()

        Assert.assertFalse("No cache should have been used", parser.isHitCache());
        Assert.assertTrue(parser.getJSON("test.internal") instanceof JSONObject);
        Assert.assertFalse("No cache should have been used", parser.isHitCache());

        parser = new JSONParser();
        parser.parseJSON("{test : { internal : {level : 2}}}");
        parser.setCachePolicy(JSONParser.CachePolicy.CACHE_ALL_LEVELS);
        Assert.assertEquals(2, parser.getInt("test.internal.level"));
        Assert.assertFalse("No cache should have been used", parser.isHitCache());

        Assert.assertTrue(parser.getJSON("test") instanceof JSONObject);
View Full Code Here

Examples of com.xmage.ws.util.json.JSONParser.parseJSON()

    }

    @Test
    public void testExtendedIndexes() throws Exception {
        JSONParser parser = new JSONParser();
        parser.parseJSON("{\"test\" : [1,2,3,4,5]}");
        Assert.assertEquals(1, parser.getInt("test[].$first"));
        Assert.assertEquals(2, parser.getInt("test[].$second"));
        Assert.assertEquals(3, parser.getInt("test[].$third"));
        Assert.assertEquals(4, parser.getInt("test[].$fourth"));
        Assert.assertEquals(5, parser.getInt("test[].$fifth"));
View Full Code Here

Examples of com.xmage.ws.util.json.JSONParser.parseJSON()

        Assert.assertEquals(3, parser.getInt("test[].$third"));
        Assert.assertEquals(4, parser.getInt("test[].$fourth"));
        Assert.assertEquals(5, parser.getInt("test[].$fifth"));

        parser = new JSONParser();
        parser.parseJSON("{\"test\" : [{1:1},{2:2},{3:3},{4:4},{5:5}]}");
        Assert.assertEquals(1, parser.getInt("test[].$first.1"));
        Assert.assertEquals(2, parser.getInt("test[].$second.2"));
        Assert.assertEquals(3, parser.getInt("test[].$third.3"));
        Assert.assertEquals(4, parser.getInt("test[].$fourth.4"));
        Assert.assertEquals(5, parser.getInt("test[].$fifth.5"));
View Full Code Here

Examples of com.xmage.ws.util.json.JSONParser.parseJSON()

        Assert.assertEquals(3, parser.getInt("test[].$third.3"));
        Assert.assertEquals(4, parser.getInt("test[].$fourth.4"));
        Assert.assertEquals(5, parser.getInt("test[].$fifth.5"));

        parser = new JSONParser();
        parser.parseJSON("{\"contacts\": {\"phones\": [\n" +
                "   {\"phone\": \"100000\"},\n" +
                "   {\"phone\": \"+7 999 1234567\"}\n" +
                "  ]}}");

        Assert.assertEquals("100000", parser.getString("contacts.phones[].$first.phone"));
View Full Code Here

Examples of com.xmage.ws.util.json.JSONParser.parseJSON()

        XMageStatsService xMageStatsService = new XMageStatsService();

        Response response = xMageStatsService.getAllStats();

        JSONParser parser = new JSONParser();
        parser.parseJSON((String) response.getEntity());

        Assert.assertEquals(DomainErrors.Errors.STATUS_OK.getCode(), parser.getInt("code"));
        System.out.println("response = " + response.getEntity().toString());
    }
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.