Example usage for com.fasterxml.jackson.databind.node ObjectNode ObjectNode

List of usage examples for com.fasterxml.jackson.databind.node ObjectNode ObjectNode

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind.node ObjectNode ObjectNode.

Prototype

public ObjectNode(JsonNodeFactory paramJsonNodeFactory) 

Source Link

Usage

From source file:com.redhat.lightblue.metadata.parser.JSONMetadataParserTest.java

License:asdf

@Test
public void putValueBigDecimal() {
    ObjectNode parent = new ObjectNode(factory);
    String name = "foo";
    BigDecimal value = new BigDecimal("213.55");

    parser.putValue(parent, name, value);

    JsonNode x = parent.get(name);/*from ww  w. j  av a  2s  .  c o m*/

    Assert.assertNotNull(x);
    Assert.assertEquals(value, x.decimalValue());
}

From source file:com.redhat.lightblue.metadata.parser.JSONMetadataParserTest.java

License:asdf

@Test
public void putValueBigInteger() {
    ObjectNode parent = new ObjectNode(factory);
    String name = "foo";
    BigInteger value = new BigInteger("123444");

    parser.putValue(parent, name, value);

    JsonNode x = parent.get(name);/*from   w w w  .j  av  a 2 s  . c  o m*/

    Assert.assertNotNull(x);
    Assert.assertEquals(value, x.bigIntegerValue());
}

From source file:com.redhat.lightblue.metadata.parser.JSONMetadataParserTest.java

License:asdf

@Test
public void putValueDouble() {
    ObjectNode parent = new ObjectNode(factory);
    String name = "foo";
    Double value = new Double("12928.222");

    parser.putValue(parent, name, value);

    JsonNode x = parent.get(name);//www  . j a va2  s .  co m

    Assert.assertNotNull(x);
    Assert.assertEquals(value.doubleValue(), x.doubleValue(), 0.001);
}

From source file:com.redhat.lightblue.metadata.parser.JSONMetadataParserTest.java

License:asdf

@Test
public void putValueFloat() {
    ObjectNode parent = new ObjectNode(factory);
    String name = "foo";
    Float value = new Float("123.222");

    parser.putValue(parent, name, value);

    JsonNode x = parent.get(name);/*w w  w  .j a v a2 s  . c  o  m*/

    Assert.assertNotNull(x);
    Assert.assertEquals(value.floatValue(), x.floatValue(), 0.001);
}

From source file:com.redhat.lightblue.metadata.parser.JSONMetadataParserTest.java

License:asdf

@Test
public void putValueInteger() {
    ObjectNode parent = new ObjectNode(factory);
    String name = "foo";
    Integer value = 123444;/*from   w w w . j a  v  a  2 s. c o  m*/

    parser.putValue(parent, name, value);

    JsonNode x = parent.get(name);

    Assert.assertNotNull(x);
    Assert.assertEquals(value.intValue(), x.intValue());
}

From source file:com.redhat.lightblue.metadata.parser.JSONMetadataParserTest.java

License:asdf

@Test
public void putValueLong() {
    ObjectNode parent = new ObjectNode(factory);
    String name = "foo";
    Long value = 1272722l;//from  ww w. jav a2  s .  c om

    parser.putValue(parent, name, value);

    JsonNode x = parent.get(name);

    Assert.assertNotNull(x);
    Assert.assertEquals(value.longValue(), x.longValue());
}

From source file:org.jetbrains.webdemo.handlers.ServerHandler.java

private void sendSessionInfo(HttpServletRequest request, HttpServletResponse response,
        SessionInfo sessionInfo) {/*from  w w w  . j ava  2 s  .  c o  m*/
    try {
        String id = sessionInfo.getId();
        ObjectNode responseBody = new ObjectNode(JsonNodeFactory.instance);
        responseBody.put("id", id);
        responseBody.put("isLoggedIn", sessionInfo.getUserInfo().isLogin());
        writeResponse(request, response, responseBody.toString(), HttpServletResponse.SC_OK);
    } catch (Throwable e) {
        ErrorWriter.ERROR_WRITER.writeExceptionToExceptionAnalyzer(e, "UNKNOWN", sessionInfo.getOriginUrl(),
                request.getRequestURI() + "?" + request.getQueryString());
    }
}

From source file:com.redhat.lightblue.metadata.parser.JSONMetadataParserTest.java

License:asdf

@Test
public void putValueSohrt() {
    ObjectNode parent = new ObjectNode(factory);
    String name = "foo";
    Short value = 123;/* ww w.jav  a  2 s.  c  o  m*/

    parser.putValue(parent, name, value);

    JsonNode x = parent.get(name);

    Assert.assertNotNull(x);
    Assert.assertEquals(value.shortValue(), x.shortValue());
}

From source file:com.redhat.lightblue.metadata.parser.JSONMetadataParserTest.java

License:asdf

@Test
public void putValueString() {
    ObjectNode parent = new ObjectNode(factory);
    String name = "foo";
    String value = "bar";

    parser.putValue(parent, name, value);

    JsonNode x = parent.get(name);/* w ww  .  jav a2s  . c  o  m*/

    Assert.assertNotNull(x);
    Assert.assertEquals(value, x.textValue());
}

From source file:org.jetbrains.webdemo.handlers.ServerHandler.java

private void sendUserName(HttpServletRequest request, HttpServletResponse response, SessionInfo sessionInfo) {
    try {//from w  w w .ja v a2 s  .  co  m
        ObjectNode responseBody = new ObjectNode(JsonNodeFactory.instance);
        if (sessionInfo.getUserInfo().isLogin()) {
            responseBody.put("isLoggedIn", true);
            responseBody.put("userName", URLEncoder.encode(sessionInfo.getUserInfo().getName(), "UTF-8"));
            responseBody.put("type", sessionInfo.getUserInfo().getType());
        } else {
            responseBody.put("isLoggedIn", false);
        }
        writeResponse(request, response, responseBody.toString(), HttpServletResponse.SC_OK);
    } catch (Throwable e) {
        ErrorWriter.ERROR_WRITER.writeExceptionToExceptionAnalyzer(e, "UNKNOWN", sessionInfo.getOriginUrl(),
                request.getRequestURI() + "?" + request.getQueryString());
    }
}