Package net.sf.json

Examples of net.sf.json.JSON


     * Convert from JSON to XML
     */
    @Override
    public Object unmarshal(Exchange exchange, InputStream stream) throws Exception {
        Object inBody = exchange.getIn().getBody();
        JSON toConvert;
        // if the incoming object is already a JSON object, process as-is,
        // otherwise parse it as a String
        if (inBody instanceof JSON) {
            toConvert = (JSON) inBody;
        } else {
View Full Code Here


    @Test
    public void testUnmarshalJSONObject() throws Exception {
        InputStream inStream = getClass().getResourceAsStream("testMessage1.json");
        String in = context.getTypeConverter().convertTo(String.class, inStream);
        JSON json = JSONSerializer.toJSON(in);

        MockEndpoint mockXML = getMockEndpoint("mock:xml");
        mockXML.expectedMessageCount(1);
        mockXML.message(0).body().isInstanceOf(String.class);
View Full Code Here

 
  @Deprecated
  public String ConvertToXML(String jsonData)
  {
    XMLSerializer serializer = new XMLSerializer();
        JSON json = JSONSerializer.toJSON(jsonData);
        serializer.setRootName("xmlOutput");
        serializer.setTypeHintsEnabled(false);
        String xml = serializer.write(json);   
    return xml;
  }
View Full Code Here

  }
 
  public void convertToXML()
  {
    XMLSerializer serializer = new XMLSerializer();
        JSON json = JSONSerializer.toJSON(this.getJsonInput());
        serializer.setRootName("xmlOutput");
        serializer.setTypeHintsEnabled(false);
        setXmlOutput(serializer.write(json));
  }
View Full Code Here

    }

    @Deprecated
    private String ConvertToXML(String jsonData) {
        XMLSerializer serializer = new XMLSerializer();
        JSON json = JSONSerializer.toJSON(jsonData);
        serializer.setRootName("xmlOutput");
        serializer.setTypeHintsEnabled(false);
        String xml = serializer.write(json);
        return xml;
    }
View Full Code Here

        return xml;
    }

    private void convertToXML() {
        XMLSerializer serializer = new XMLSerializer();
        JSON json = JSONSerializer.toJSON(this.getJsonInput());
        serializer.setRootName("xmlOutput");
        serializer.setTypeHintsEnabled(false);
        setXmlOutput(serializer.write(json));
    }
View Full Code Here

            stderr.println(e.getMessage());
            return CliUtils.Status.ERR_NO_METADATA.code();
        }
        if (container != null) {
            container.getACL().checkPermission(PluginImpl.READ_METADATA);
            JSON json = container.toJson();
            stdout.println(json.toString());
        } else {
            stderr.println("No metadata container found.");
            return CliUtils.Status.ERR_BAD_CMD.code();
        }
View Full Code Here

        if (container != null) {
            container.getACL().checkPermission(PluginImpl.UPDATE_METADATA);
            if (replace) {
                container.getACL().checkPermission(PluginImpl.REPLACE_METADATA);
            }
            JSON json = JSONSerializer.toJSON(dataDocument);
            try {
                List<MetadataValue> values = JsonUtils.toValues(json, container);
                if (replace) {
                    ParentUtil.replaceChildren(container, values);
                } else {
View Full Code Here

        if (container != null) {
            container.getACL().checkPermission(PluginImpl.UPDATE_METADATA);
            if (params.isReplace()) {
                container.getACL().checkPermission(PluginImpl.REPLACE_METADATA);
            }
            JSON json = JSONSerializer.toJSON(dataDocument);
            try {
                List<MetadataValue> values = JsonUtils.toValues(json, container);
                if (params.isReplace()) {
                    ParentUtil.replaceChildren(container, values);
                    sendOk(response);
View Full Code Here

            sendError(CliUtils.Status.ERR_NO_METADATA, e.getMessage(), response);
            return;
        }
        if (container != null) {
            container.getACL().checkPermission(PluginImpl.READ_METADATA);
            JSON json = container.toJson();
            response.setContentType(CONTENT_TYPE);
            response.getOutputStream().print(json.toString());
        } else {
            sendError(CliUtils.Status.ERR_BAD_CMD, "No metadata container found.", response);
        }
    }
View Full Code Here

TOP

Related Classes of net.sf.json.JSON

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.