Megala

Is
https://docs.wso2.com/display/CEP400/Inbuilt+Functions#InbuiltFunctions-convertconvert
what you expect?

Thanks,
Ralph


On Tue, Dec 6, 2016 at 11:48 AM, Megala Uthayakumar <meg...@wso2.com> wrote:

>
> Hi All,
>
> In IOT analytics, we have a requirement of writing siddhi extension to get
> the value for a particular json property when the json string and property
> name are passed as parameters. The extension can be used as below,
>
> *json:getProperty("jsonString","property_name")*
>
> Since the above function is capable of returning any type
> (Bool/long/string/..)  as return values. Initially we tried it without
> defining the return types. In that case, siddhi engine threw and exception
> saying that return type of above is null and stream definitions does not
> match. After that we tried to set the return type in execute method based
> on the value. but seems like it is required to use the init method in
> siddhi extension to set the return type. Finally what we did is to use the
> third parameter which would indicate the type required for the return type
> as follow,
>
> if we need a double
>
> *json.getProperty("jsonString", "latitude", 0.0d);*
>
> if we need a long,
>
> *json.getProperty(("jsonString", "timestamp", 0l);*
>
> Is there any better way of achieving this ? or do we have a cast function
> for string, so that we can later cast the value to a desired type?
>
> Thanks.
>
> Regards,
> Megala
> --
> Megala Uthayakumar
>
> Software Engineer
> Mobile : 0779967122
>
> _______________________________________________
> Dev mailing list
> Dev@wso2.org
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to