Package com.sun.jersey.api.json

Examples of com.sun.jersey.api.json.JSONJAXBContext


   * @param s the JSON representation of the filter
   * @return the filter
   * @throws Exception
   */
  public static Filter buildFilter(String s) throws Exception {
    JSONJAXBContext context =
      new JSONJAXBContext(JSONConfiguration.natural().build(),
        FilterModel.class);
    JSONUnmarshaller unmarshaller = context.createJSONUnmarshaller();
    FilterModel model = unmarshaller.unmarshalFromJSON(new StringReader(s),
      FilterModel.class);
    return model.build();
  }
View Full Code Here


   * @param filter the filter
   * @return the JSON representation of the filter
   * @throws Exception
   */
  public static String stringifyFilter(final Filter filter) throws Exception {
    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();
  }
View Full Code Here

  };

  @SuppressWarnings("unchecked")
  public JAXBContextResolver() throws Exception {
    this.types = new HashSet(Arrays.asList(cTypes));
    this.context = new JSONJAXBContext(JSONConfiguration.natural().build(),
      cTypes);
  }
View Full Code Here

   * @param s the JSON representation of the filter
   * @return the filter
   * @throws Exception
   */
  public static Filter buildFilter(String s) throws Exception {
    JSONJAXBContext context =
      new JSONJAXBContext(JSONConfiguration.natural().build(),
        FilterModel.class);
    JSONUnmarshaller unmarshaller = context.createJSONUnmarshaller();
    FilterModel model = unmarshaller.unmarshalFromJSON(new StringReader(s),
      FilterModel.class);
    return model.build();
  }
View Full Code Here

   * @param filter the filter
   * @return the JSON representation of the filter
   * @throws Exception
   */
  public static String stringifyFilter(final Filter filter) throws Exception {
    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();
  }
View Full Code Here

   * @param s the JSON representation of the filter
   * @return the filter
   * @throws Exception
   */
  public static Filter buildFilter(String s) throws Exception {
    JSONJAXBContext context =
      new JSONJAXBContext(JSONConfiguration.natural().build(),
        FilterModel.class);
    JSONUnmarshaller unmarshaller = context.createJSONUnmarshaller();
    FilterModel model = unmarshaller.unmarshalFromJSON(new StringReader(s),
      FilterModel.class);
    return model.build();
  }
View Full Code Here

   * @param filter the filter
   * @return the JSON representation of the filter
   * @throws Exception
   */
  public static String stringifyFilter(final Filter filter) throws Exception {
    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();
  }
View Full Code Here

        tryConfiguration(JSONConfiguration.mapped().xml2JsonNs(ns2json).nsSeparator(':').rootUnwrapping(false).build());
    }

    private void tryConfiguration(JSONConfiguration configuration) throws Exception {

        final JSONJAXBContext ctx = new JSONJAXBContext(configuration, NamespaceBeanWithAttribute.class);
        final JSONMarshaller jm = ctx.createJSONMarshaller();
        final JSONUnmarshaller ju = ctx.createJSONUnmarshaller();


        NamespaceBeanWithAttribute beanTwo;

        final StringWriter sw = new StringWriter();
View Full Code Here

*/
public class XmlTypeTest extends TestCase {

    public void testSimpleXmlTypeBean() throws Exception {
       
        final JSONJAXBContext ctx = new JSONJAXBContext(SimpleXmlTypeBean.class);
        final JSONMarshaller jm = ctx.createJSONMarshaller();
        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);
View Full Code Here

*/
public class FormattingOptionTest extends TestCase {

    public void testNoNewLinesAdded() throws Exception {

        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);

View Full Code Here

TOP

Related Classes of com.sun.jersey.api.json.JSONJAXBContext

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.