Package com.sun.jersey.api.json

Examples of com.sun.jersey.api.json.JSONConfiguration$MappedBuilder


            configBuilder.nonStrings(nonString);
        }
        for (String attrAsElem : attrAsElements) {
            configBuilder.attributeAsElement(attrAsElem);
        }
        JSONConfiguration config = configBuilder.build();
        tryWritingBean(jaxbBean, filename, config);
        tryReadingBean(filename, jaxbBean, config);
    }
View Full Code Here


    @Override
    public final void writeList(Class<?> elementType, Collection<?> t, MediaType mediaType, Charset c, Marshaller m, OutputStream entityStream) throws JAXBException, IOException {
        final OutputStreamWriter osw = new OutputStreamWriter(entityStream, c);

        JSONConfiguration origJsonConfig = JSONConfiguration.DEFAULT;
        if (m instanceof JSONConfigurated) {
            origJsonConfig = ((JSONConfigurated)m).getJSONConfiguration();
        }

        final JSONConfiguration unwrappingJsonConfig =
                JSONConfiguration.createJSONConfigurationWithRootUnwrapping(origJsonConfig, true);

        final XMLStreamWriter jxsw = Stax2JsonFactory.createWriter(osw, unwrappingJsonConfig, elementType, getStoredJAXBContext(elementType), true);
        final String invisibleRootName = getRootElementName(elementType);
        final String elementName = getElementName(elementType);
View Full Code Here

        }
    }

    @Override
    protected final XMLStreamReader getXMLStreamReader(Class<?> elementType, MediaType mediaType, Unmarshaller u, InputStream entityStream) throws XMLStreamException {
        JSONConfiguration c = JSONConfiguration.DEFAULT;
        final Charset charset = getCharset(mediaType);
        if (u instanceof JSONConfigurated) {
            c = ((JSONConfigurated) u).getJSONConfiguration();
        }
View Full Code Here

        final JSONConfiguration.NaturalBuilder builder = JSONConfiguration.natural();
        builder.usePrefixesAtNaturalAttributes();
        builder.rootUnwrapping(false);

        final JSONConfiguration jsonConfiguration = builder.build();
        final JAXBContext jaxbContext = JAXBContext.newInstance(classes, props);

        tryBean(Jersey1199List.class, "jersey1199_natural.json", Jersey1199List.createTestInstance(), jaxbContext, jsonConfiguration);
    }
View Full Code Here

  public JAXBContextResolver() throws Exception {
    types.add( ArrayList.class );
    types.add( JaxbList.class );
    arrays.add( "list" );
    arrays.add( "values" );
    JSONConfiguration config =
        JSONConfiguration.mapped().rootUnwrapping( true ).arrays( arrays.toArray( new String[] {} ) ).build();
    context = new JSONJAXBContext( config, types.toArray( new Class[] {} ) );
  }
View Full Code Here

    String simpleName = objectType.getSimpleName();
    simpleName = simpleName.substring( 0, 1 ).toLowerCase() + simpleName.substring( 1 );
    arrays.add( simpleName );
    try {
      JSONConfiguration config =
          JSONConfiguration.mapped().rootUnwrapping( true ).arrays( arrays.toArray( new String[arrays.size()] ) )
              .build();

      synchronized ( types ) {
        types.add( objectType );
View Full Code Here

    private JAXBContext context;
    private Class<?>[] types = { MapResult.class };

    public JsonJaxbProvider() throws Exception {
        JSONConfiguration config = JSONConfiguration.natural().build();
        context = new JSONJAXBContext(config, types);
    }
View Full Code Here

    @Override
    public final void writeList(Class<?> elementType, Collection<?> t, MediaType mediaType, Charset c, Marshaller m, OutputStream entityStream) throws JAXBException, IOException {
        final OutputStreamWriter osw = new OutputStreamWriter(entityStream, c);

        JSONConfiguration origJsonConfig = JSONConfiguration.DEFAULT;
        if (m instanceof JSONConfigurated) {
            origJsonConfig = ((JSONConfigurated)m).getJSONConfiguration();
        }

        final JSONConfiguration unwrappingJsonConfig =
                JSONConfiguration.createJSONConfigurationWithRootUnwrapping(origJsonConfig, true);

        final XMLStreamWriter jxsw = Stax2JsonFactory.createWriter(osw, unwrappingJsonConfig, true);
        final String invisibleRootName = getRootElementName(elementType);
        final String elementName = getElementName(elementType);
View Full Code Here

        }
    }

    @Override
    protected final XMLStreamReader getXMLStreamReader(Class<?> elementType, MediaType mediaType, Unmarshaller u, InputStream entityStream) throws XMLStreamException {
        JSONConfiguration c = JSONConfiguration.DEFAULT;
        final Charset charset = getCharset(mediaType);
        if (u instanceof JSONConfigurated) {
            c = ((JSONConfigurated) u).getJSONConfiguration();
        }
        return Stax2JsonFactory.createReader(new InputStreamReader(entityStream, charset), c, JSONHelper.getRootElementName((Class)elementType), true);
View Full Code Here

            configBuilder.nonStrings(nonString);
        }
        for (String attrAsElem : attrAsElements) {
            configBuilder.attributeAsElement(attrAsElem);
        }
        JSONConfiguration config = configBuilder.build();
        tryWritingBean(jaxbBean, filename, config);
        tryReadingBean(filename, jaxbBean, config);
    }
View Full Code Here

TOP

Related Classes of com.sun.jersey.api.json.JSONConfiguration$MappedBuilder

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.