Examples of marshallToJSON()


Examples of com.sun.jersey.api.json.JSONMarshaller.marshallToJSON()

    JSONJAXBContext context =
      new JSONJAXBContext(JSONConfiguration.natural().build(),
        FilterModel.class);
    JSONMarshaller marshaller = context.createJSONMarshaller();
    StringWriter writer = new StringWriter();
    marshaller.marshallToJSON(new FilterModel(filter), writer);
    return writer.toString();
  }

  private static final byte[] COLUMN_DIVIDER = Bytes.toBytes(":");
View Full Code Here

Examples of com.sun.jersey.api.json.JSONMarshaller.marshallToJSON()

    JSONJAXBContext context =
      new JSONJAXBContext(JSONConfiguration.natural().build(),
        FilterModel.class);
    JSONMarshaller marshaller = context.createJSONMarshaller();
    StringWriter writer = new StringWriter();
    marshaller.marshallToJSON(new FilterModel(filter), writer);
    return writer.toString();
  }

  private static final byte[] COLUMN_DIVIDER = Bytes.toBytes(":");
View Full Code Here

Examples of com.sun.jersey.api.json.JSONMarshaller.marshallToJSON()

        NamespaceBeanWithAttribute beanTwo;

        final StringWriter sw = new StringWriter();

        jm.marshallToJSON(one, sw);

        System.out.println(String.format("%s", sw));

        beanTwo = ju.unmarshalFromJSON(new StringReader(sw.toString()), NamespaceBeanWithAttribute.class);
View Full Code Here

Examples of com.sun.jersey.api.json.JSONMarshaller.marshallToJSON()

        final JSONUnmarshaller ju = ctx.createJSONUnmarshaller();
        final StringWriter sw = new StringWriter();

        final SimpleXmlTypeBean one= JSONTestHelper.createTestInstance(SimpleXmlTypeBean.class);
        SimpleXmlTypeBean two;
        jm.marshallToJSON(new JAXBElement<SimpleXmlTypeBean>(new QName("test"), SimpleXmlTypeBean.class, one), sw);
        two = ju.unmarshalFromJSON(new StringReader(sw.toString()), SimpleXmlTypeBean.class);
        assertEquals(one, two);
    }
}
View Full Code Here

Examples of com.sun.jersey.api.json.JSONMarshaller.marshallToJSON()

        final JSONJAXBContext ctx = new JSONJAXBContext(JSONConfiguration.natural().rootUnwrapping(false).humanReadableFormatting(false).build(), User.class);
        final JSONMarshaller jm = ctx.createJSONMarshaller();
        final StringWriter sw = new StringWriter();

        final User one = JSONTestHelper.createTestInstance(User.class);
        jm.marshallToJSON(one, sw);

        assertFalse(sw.toString().contains("\n"));
    }

    public void testNewLineAdded() throws Exception {
View Full Code Here

Examples of com.sun.jersey.api.json.JSONMarshaller.marshallToJSON()

        final JSONJAXBContext ctx = new JSONJAXBContext(JSONConfiguration.natural().rootUnwrapping(false).humanReadableFormatting(true).build(), User.class);
        final JSONMarshaller jm = ctx.createJSONMarshaller();
        final StringWriter sw = new StringWriter();

        final User one = JSONTestHelper.createTestInstance(User.class);
        jm.marshallToJSON(one, sw);

        assertTrue(sw.toString().contains("\n"));
    }

}
View Full Code Here

Examples of com.sun.jersey.api.json.JSONMarshaller.marshallToJSON()

        final JSONUnmarshaller ju = ctx.createJSONUnmarshaller();
        final StringWriter sw = new StringWriter();

        Fruits fruits = createFruits();

        jm.marshallToJSON(fruits, sw);

        String jsonResult = sw.toString();
        System.out.println(jsonResult);

        assertEquals("{\"fruit\":{\"name\":\"apple\",\"color\":\"red\"}}", jsonResult);
View Full Code Here

Examples of com.sun.jersey.api.json.JSONMarshaller.marshallToJSON()

        final JSONJAXBContext ctx = new JSONJAXBContext(configuration, NullStringBean.class);
        final JSONMarshaller jm = ctx.createJSONMarshaller();
        final JSONUnmarshaller ju = ctx.createJSONUnmarshaller();
        StringWriter sw = new StringWriter();
        jm.marshallToJSON(one, sw);
        System.out.println(String.format("Marshalled: %s", sw));

        NullStringBean two = ju.unmarshalFromJSON(new StringReader(sw.toString()), NullStringBean.class);

        assertEquals(one, two);
View Full Code Here

Examples of com.sun.jersey.api.json.JSONMarshaller.marshallToJSON()

        final JSONJAXBContext ctx = new JSONJAXBContext(JSONConfiguration.natural().build(), SimpleBeanWithAttributes.class);
        final JSONMarshaller jm = ctx.createJSONMarshaller();
        final StringWriter sw = new StringWriter();

        final SimpleBeanWithAttributes one = JSONTestHelper.createTestInstance(SimpleBeanWithAttributes.class);
        jm.marshallToJSON(one, sw);
        System.out.println(sw.toString());

        assertFalse(sw.toString().contains("@"));
    }
View Full Code Here

Examples of com.sun.jersey.api.json.JSONMarshaller.marshallToJSON()

        final JSONJAXBContext ctx = new JSONJAXBContext(JSONConfiguration.natural().usePrefixesAtNaturalAttributes().build(), SimpleBeanWithAttributes.class);
        final JSONMarshaller jm = ctx.createJSONMarshaller();
        final StringWriter sw = new StringWriter();

        final SimpleBeanWithAttributes one= JSONTestHelper.createTestInstance(SimpleBeanWithAttributes.class);
        jm.marshallToJSON(one, sw);
        System.out.println(sw.toString());

        assertTrue(sw.toString().contains("@"));
    }
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.