Package org.mule.module.json

Examples of org.mule.module.json.JsonData


        //and back again
        message = new DefaultMuleMessage(item, muleContext);
        String json = message.getPayload(DataType.STRING_DATA_TYPE);
        assertNotNull(json);
        assertEquals(ITEM_JSON, json);
        JsonData data = new JsonData(json);
        assertEquals("1234", data.getAsString("code"));
        assertEquals("Vacuum Cleaner", data.getAsString("description"));
        assertEquals("true", data.getAsString("in-stock"));
    }
View Full Code Here


        assertTrue(apple.isBitten());

        message=  new DefaultMuleMessage(apple, muleContext);
        String json = message.getPayload(DataTypeFactory.STRING);
        assertNotNull(json);
        JsonData data = new JsonData(json);
        assertEquals("true", data.getAsString("bitten"));
        assertEquals("false", data.getAsString("washed"));
    }
View Full Code Here

        assertTrue(apple.isBitten());

        message = new DefaultMuleMessage(apple, muleContext);
        String json = message.getPayload(DataType.STRING_DATA_TYPE);
        assertNotNull(json);
        JsonData data = new JsonData(json);
        assertEquals("true", data.get("bitten"));
        assertEquals("false", data.get("washed"));
    }
View Full Code Here

            if (src instanceof Reader)
            {
                if (getReturnDataType().equals(JSON_TYPE))
                {
                    returnValue = new JsonData((Reader) src);
                }
                else
                {
                    returnValue = getMapper().readValue((Reader) src, getReturnDataType().getType());
                }
            }
            else if (src instanceof String)
            {
                if (getReturnDataType().equals(JSON_TYPE))
                {
                    returnValue = new JsonData((String) src);
                }
                else
                {
                    returnValue = getMapper().readValue((String) src, getReturnDataType().getType());
                }
            }
            else
            {
                reader = new InputStreamReader(is, outputEncoding);
                if (getReturnDataType().equals(JSON_TYPE))
                {
                    returnValue = new JsonData(reader);
                }
                else
                {
                    returnValue = getMapper().readValue(reader, getReturnDataType().getType());
                }
View Full Code Here

        String transportMessageString = transportMessage.toString();
        if (transportMessageString.indexOf(Bayeux.DATA_FIELD) > -1)
        {
            try
            {
                JsonData data = new JsonData(transportMessageString);
                return data.get(Bayeux.DATA_FIELD).toString();
            }
            catch (IOException e)
            {
                throw new DefaultMuleException(e);
            }
View Full Code Here

        muleMessage.addProperties(messageProperties, PropertyScope.INVOCATION);
    }
   
    private void addPropertiesToFromJsonData(DefaultMuleMessage muleMessage, Object transportMessage) throws IOException
    {
        JsonData data = new JsonData(transportMessage.toString());
        if (data.hasNode(AjaxConnector.REPLYTO_PARAM))
        {
            muleMessage.setReplyTo(data.getAsString(AjaxConnector.REPLYTO_PARAM));
        }
    }
View Full Code Here

        return flickr;
    }

    public void testFlickrSearch() throws Exception
    {
        JsonData doc = getFlickr().search(SEARCH_TERM);
        assertNotNull(doc);
        assertEquals(10, ((ArrayNode) doc.get("/photos/photo")).size());
    }
View Full Code Here

        String transportMessageString = transportMessage.toString();
        if (transportMessageString.indexOf(Bayeux.DATA_FIELD) > -1)
        {
            try
            {
                JsonData data = new JsonData(transportMessageString);
                return data.get(Bayeux.DATA_FIELD).toString();
            }
            catch (IOException e)
            {
                throw new DefaultMuleException(e);
            }
View Full Code Here

        muleMessage.addProperties(messageProperties, PropertyScope.INVOCATION);
    }
   
    private void addPropertiesToFromJsonData(DefaultMuleMessage muleMessage, Object transportMessage) throws IOException
    {
        JsonData data = new JsonData(transportMessage.toString());
        if (data.hasNode(AjaxConnector.REPLYTO_PARAM))
        {
            muleMessage.setReplyTo(data.getAsString(AjaxConnector.REPLYTO_PARAM));
        }
    }
View Full Code Here

            {
                data = (JsonNode) input;
            }
            else if (input instanceof JsonData)
            {
                JsonData jsonData = (JsonData) input;
                data = JsonLoader.fromReader(new StringReader(jsonData.toString()));
            }
            else
            {
                LOGGER.warn("Payload type " + input.getClass().getName() + " is not supported");
                return false;
View Full Code Here

TOP

Related Classes of org.mule.module.json.JsonData

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.