Package net.minidev.json

Examples of net.minidev.json.JSONObject


      // ignore
    }

    if (MTGOX_TRADES_CHANNEL.equals(channel) && "Y".equals(primary)) {

      JSONObject trade = JsonPath.compile("$.trade").read(message);

      outputChannel.send(MessageBuilder.withPayload(trade.toString()).build());

      // Example message:
      // {"channel":"dbf1dee9-4f2e-4a08-8cb7-748919a71b21","op":"private","origin":"broadcast","private":"trade","trade":{"amount":0.01,"amount_int":"1000000","date":1342989115,"item":"BTC","price":8.50097,"price_currency":"USD","price_int":"850097","primary":"Y","properties":"limit","tid":"1342989115044532","trade_type":"bid","type":"trade"}}
      logger.debug("Published trade: " + trade);
    }
View Full Code Here


      // ignore
    }

    if (MTGOX_TRADES_CHANNEL.equals(channel) && "Y".equals(primary)) {

      JSONObject trade = JsonPath.compile("$.trade").read(message);
      this.broadcaster.broadcast(trade.toString());

      // Example message:
      // {"channel":"dbf1dee9-4f2e-4a08-8cb7-748919a71b21","op":"private","origin":"broadcast","private":"trade","trade":{"amount":0.01,"amount_int":"1000000","date":1342989115,"item":"BTC","price":8.50097,"price_currency":"USD","price_int":"850097","primary":"Y","properties":"limit","tid":"1342989115044532","trade_type":"bid","type":"trade"}}
      logger.debug("Published trade: " + trade);
    }
View Full Code Here

    catch (Exception ex) {
      // ignore
    }

    if (MTGOX_TRADES_CHANNEL.equals(channel) && "Y".equals(primary)) {
      JSONObject trade = JsonPath.compile("$.trade").read(message.getPayload());
      logger.info("Broadcasting Trade: {}", trade);
      serverWebSocketSessionsStore.sendToAll(new TextMessage(message.getPayload()));
    }
    else {
      // ignore any non-trade messages that might slip in before our
View Full Code Here

      // ignore
    }

    if (MTGOX_TRADES_CHANNEL.equals(channel) && "Y".equals(primary)) {

      JSONObject trade = JsonPath.compile("$.trade").read(message);

      logger.info("Broadcasting Message: " + message);
      MetaBroadcaster.getDefault().broadcastTo("/", message);

      // Example message:
View Full Code Here

    @Test
    public void testJSONEventLayoutHasKeys() {
        logger.info("this is a test message");
        String message = appender.getMessages()[0];
        Object obj = JSONValue.parse(message);
        JSONObject jsonObject = (JSONObject) obj;

        for (String fieldName : logstashFields) {
            Assert.assertTrue("Event does not contain field: " + fieldName, jsonObject.containsKey(fieldName));
        }
    }
View Full Code Here

    @Test
    public void testJSONEventLayoutHasFieldLevel() {
        logger.fatal("this is a new test message");
        String message = appender.getMessages()[0];
        Object obj = JSONValue.parse(message);
        JSONObject jsonObject = (JSONObject) obj;
        JSONObject atFields = (JSONObject) jsonObject.get("@fields");

        Assert.assertEquals("Log level is wrong", "FATAL", atFields.get("level"));
    }
View Full Code Here

        String ndcData = new String("json-layout-test");
        NDC.push(ndcData);
        logger.warn("I should have NDC data in my log");
        String message = appender.getMessages()[0];
        Object obj = JSONValue.parse(message);
        JSONObject jsonObject = (JSONObject) obj;
        JSONObject atFields = (JSONObject) jsonObject.get("@fields");

        Assert.assertEquals("NDC is wrong", ndcData, atFields.get("ndc"));
    }
View Full Code Here

    public void testJSONEventLayoutHasMDC() {
        MDC.put("foo","bar");
        logger.warn("I should have MDC data in my log");
        String message = appender.getMessages()[0];
        Object obj = JSONValue.parse(message);
        JSONObject jsonObject = (JSONObject) obj;
        JSONObject atFields = (JSONObject) jsonObject.get("@fields");
        JSONObject mdcData = (JSONObject) atFields.get("mdc");

        Assert.assertEquals("MDC is wrong","bar", mdcData.get("foo"));
    }
View Full Code Here

    public void testJSONEventLayoutExceptions() {
        String exceptionMessage = new String("shits on fire, yo");
        logger.fatal("uh-oh", new IllegalArgumentException(exceptionMessage));
        String message = appender.getMessages()[0];
        Object obj = JSONValue.parse(message);
        JSONObject jsonObject = (JSONObject) obj;
        JSONObject atFields = (JSONObject) jsonObject.get("@fields");
        JSONObject exceptionInformation = (JSONObject) atFields.get("exception");

        Assert.assertEquals("Exception class missing", "java.lang.IllegalArgumentException", exceptionInformation.get("exception_class"));
        Assert.assertEquals("Exception exception message", exceptionMessage, exceptionInformation.get("exception_message"));
    }
View Full Code Here

    @Test
    public void testJSONEventLayoutHasClassName() {
        logger.warn("warning dawg");
        String message = appender.getMessages()[0];
        Object obj = JSONValue.parse(message);
        JSONObject jsonObject = (JSONObject) obj;
        JSONObject atFields = (JSONObject) jsonObject.get("@fields");

        Assert.assertEquals("Logged class does not match", this.getClass().getCanonicalName().toString(), atFields.get("class"));
    }
View Full Code Here

TOP

Related Classes of net.minidev.json.JSONObject

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.