Specifying an "evaluator" attribute means we expect that the incoming
payload type should be known in advance. I'll go ahead with the approach u
suggested and try to finish it off EOD today.

Thanks.


On Fri, Apr 5, 2013 at 10:07 AM, Kasun Indrasiri <[email protected]> wrote:

> Lets go ahead with this approach and finish it off.
> Can we complete backend with above changes by today itself.. and send the
> required patches/samples so that we can do local testing?
>
>
> ---------- Forwarded message ----------
> From: Kasun Indrasiri <[email protected]>
> Date: Fri, Apr 5, 2013 at 7:45 AM
> Subject: Re: [ESB] Enhancing PayloadFactory Mediator
> To: Nalin Chandraratne <[email protected]>
> Cc: support-dev-group <[email protected]>, Miyuru Wanninayaka <
> [email protected]>, Dushan Abeyruwan <[email protected]>
>
>
> The scenario here is that, based on the incoming message format we have to
> selectively extract data. There is no standard language currently for
> querying JSON as we do with XPath for XML.
> So, if the incoming type is XML then obviously we can use xpath, while
> when the incoming type is json, we need to use some thing similar
> to following. [1] & [2]
>
> For XML : /store/book[1]/title
> JSON : x.store.book[0].title
>
>
> Therefore we need a way to specify the incoming message format in payload
> factory mediator. So, how about specifying an evaluator  as part of the PF
> declaration.
>
>  <payloadFactory media-type="application/json" evaluator="json">
>         <format>
>             {“a” : "c", “b” : “$1”}
>         </format>
>         <args>
>             <arg expression="x.store.book[0].title"/>
>         </args>
> </payloadFactory>
>
> As per the offline discussion we had yesterday, we could use JSON-Path
> which is under Apache License 2.0.
>
> (This discussion should take place in architecture or dev :))
>
> [1] http://code.google.com/p/json-path/
> [2] http://goessner.net/articles/JsonPath/
>
>
>
> On Fri, Apr 5, 2013 at 12:44 AM, Nalin Chandraratne <[email protected]>wrote:
>
>>  http://code.google.com/p/json-path/
>>
>> A suggestion by Dushan.
>>
>>
>> On Fri, Apr 5, 2013 at 12:38 AM, Nalin Chandraratne <[email protected]>wrote:
>>
>>> Hi,
>>>
>>> I'm currently working on $subject and we are adding the json support to
>>> PF. Currently, to extract values from the incoming
>>>
>>> xml payload, we use xpath. But now we have incoming json payload as well
>>> and there is no standard method or notations to
>>>
>>> extract the content from json payload. For the time being we are using
>>> something like "/root/parent/child" to traverse
>>>
>>> through the hierachy. We have to consider json arrays as well.
>>>
>>> [1] Please suggest a solid way to do this.
>>>
>>> Next thing is, for a given PF, expressions to extract values from the
>>> incoming payload are defined assuming we know the  content-type in advance.
>>> (Because for xml it would be xpath and for json its [1]).
>>>
>>> [2] Does a given PF need to be compatible with both the content-types?
>>> [3] if so, how can we define expressions that would be compliant with
>>> both xml and json?
>>>  [4] Is it ok to define 2 expressions one for each content-type?
>>>
>>> Your comments and suggestions on 1,2,3,4 are welcome.
>>>
>>> Thanks,
>>> Nalin.
>>>
>>
>>
>
>
> --
> Kasun Indrasiri
> Associate Technical Lead
> WSO2, Inc.; http://wso2.com
> lean.enterprise.middleware
>
> cell: +94 71 536 4128
> Blog : http://kasunpanorama.blogspot.com/
>
>
>
> --
> Kasun Indrasiri
> Associate Technical Lead
> WSO2, Inc.; http://wso2.com
> lean.enterprise.middleware
>
> cell: +94 71 536 4128
> Blog : http://kasunpanorama.blogspot.com/
>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to