Hi Joe, is this dynamic Property works today with AttributesToJSON today?
property name: rt_firstbyte property value: Integer -Madhu On Sat, Mar 26, 2016 at 1:13 PM, Joe Witt <joe.w...@gmail.com> wrote: > What Madhukar is trying to do seems totally reasonable. As an > alternative to Bryan's proposal what do you all think about updating > the behavior of AttributesToJSON to allow the user to suggest the type > information they would like for a given attribute? It's default > behavior is as is which is it will encode it as a string but I'm > suggesting the user be able to list certain attribute names as dynamic > properties and their desired serialized type as the value of that > property. So for instance he could add a dynamic property to > AttributesToJSON which would be > > property name: rt_firstbyte > property value: Integer > > If any of the supplied type hints result in conversion failures then > we route to failure. > > Thanks > Joe > > On Fri, Mar 25, 2016 at 12:59 PM, Bryan Bende <bbe...@gmail.com> wrote: > > Depending how many attributes you are dealing with, a possible work > around > > could be to construct the JSON with a ReplaceText text processor. > > > > If you have ReplaceText after your UpdateAttribute, you could set the > > Replacement Value to a String like: > > > > { "rt_firstbyte" : ${http.param.t_resp}, "rt_lastbyte" : > > ${http.param.t_page}, "rt_loadtime" : ${http.param.t_done} } > > > > In the long-term, maybe AttributesToJson could follow a convention where > it > > looks for optional attributes that have the same name as another > attribute, > > but end with have ".type" ? > > > > So in your example there would be: > > > > rt_firstbyte ${http.param.t_resp} > > rt_firstbyte.type int > > > > If it doesn't find a type attribute then it defaults to String as it does > > today. > > Just an idea of how we can provide type information, I'm sure there are > > other options too. > > > > -Bryan > > > > On Fri, Mar 25, 2016 at 12:07 PM, Madhukar Thota < > madhukar.th...@gmail.com> > > wrote: > >> > >> Joe, > >> > >> I attached the screenshot for UpdateAttributes and AttributesToJson. > >> Please let me know if this is not something your are looking for. > >> > >> On Fri, Mar 25, 2016 at 11:58 AM, Joe Witt <joe.w...@gmail.com> wrote: > >>> > >>> Ok and can you share the config settings you have in Attributes to > >>> JSON at this time? We do need to make changes for this probably but > >>> want to understand what will be a good path forward. > >>> > >>> On Fri, Mar 25, 2016 at 9:49 AM, Madhukar Thota > >>> <madhukar.th...@gmail.com> wrote: > >>> > Hi Joe, > >>> > > >>> > In my UpdateAtrribute, i am converting the string values to Number > >>> > like > >>> > this: > >>> > > >>> > rt_firstbyte ${http.param.t_resp:toNumber()} > >>> > rt_lastbyte ${http.param.t_page:toNumber()} > >>> > rt_loadtime ${http.param.t_done:toNumber()} > >>> > > >>> > when i pass this attribute to AttributeToJson processor, the type > >>> > should be > >>> > properly serialized but here is what i am getting from > AttributeToJson > >>> > processor > >>> > > >>> > > >>> > {"rt_loadtime":"260","rt_firstbyte":"20","referrer":" > http://localhost:63342/Beacon/test.html","rt_lastbyte":"240"} > >>> > > >>> > This what i expect > >>> > > >>> > > >>> > {"rt_loadtime":260,"rt_firstbyte":20,"referrer":" > http://localhost:63342/Beacon/test.html","rt_lastbyte":240} > >>> > > >>> > Thanks > >>> > > >>> > On Fri, Mar 25, 2016 at 10:47 AM, Joe Witt <joe.w...@gmail.com> > wrote: > >>> >> > >>> >> Chase, > >>> >> > >>> >> To unsubscribe send an e-mail here > users-unsubscr...@nifi.apache.org > >>> >> > >>> >> Madhukar, > >>> >> > >>> >> As Bryan mentioned attributes are always serialized as Strings. > Their > >>> >> type is really a function of when they are being evaluated/used. > Can > >>> >> you describe a bit more about what you'd like AttributesToJson to do > >>> >> with a given attribute that is of type Int/Long/etc..? > >>> >> > >>> >> Thanks > >>> >> Joe > >>> >> > >>> >> > >>> >> > >>> >> On Fri, Mar 25, 2016 at 8:01 AM, Chase Cunningham < > ch...@thecynja.com> > >>> >> wrote: > >>> >> > unsubscribe > >>> >> > > >>> >> > > >>> >> > On 3/25/16 9:01 AM, Madhukar Thota wrote: > >>> >> > > >>> >> > Any Other ways to achieve this? > >>> >> > > >>> >> > On Thu, Mar 24, 2016 at 4:48 PM, Bryan Bende <bbe...@gmail.com> > >>> >> > wrote: > >>> >> >> > >>> >> >> I think the problem is that all attributes are actually Strings > >>> >> >> internally, even after calling toNumber() that is only temporary > >>> >> >> while > >>> >> >> the > >>> >> >> expression language is executing. > >>> >> >> > >>> >> >> So by the time it gets to AttributesToJson it doesn't have any > >>> >> >> information > >>> >> >> about the type of each attribute and they all end up as Strings. > I > >>> >> >> think we > >>> >> >> would have to come up with a way to pass some type information > >>> >> >> along to > >>> >> >> AttributesToJson in order to get something other than Strings. > >>> >> >> > >>> >> >> -Bryan > >>> >> >> > >>> >> >> > >>> >> >> On Thu, Mar 24, 2016 at 3:30 PM, Madhukar Thota > >>> >> >> <madhukar.th...@gmail.com> > >>> >> >> wrote: > >>> >> >>> > >>> >> >>> Hi i am trying to convert string value to integer in > >>> >> >>> UpdateAtrributes > >>> >> >>> using toNumber like this > >>> >> >>> > >>> >> >>> > >>> >> >>> ${http.param.t_resp:toNumber()} where http.param.t_resp = "132" > >>> >> >>> > >>> >> >>> but when the fileattribute pushed to Attributetojson processor > , i > >>> >> >>> am > >>> >> >>> stilling seeing it as string. Am i am doing something wrong? and > >>> >> >>> also > >>> >> >>> how > >>> >> >>> can i convert string to float? > >>> >> >>> > >>> >> >>> > >>> >> >>> > >>> >> >>> > >>> >> >> > >>> >> > > >>> >> > > >>> >> > -- > >>> >> > Dr. Chase C Cunningham > >>> >> > CTRC (SW) USN Ret. > >>> >> > The Cynja LLC Proprietary Business and Technical Information > >>> >> > CONFIDENTIAL TREATMENT REQUIRED > >>> > > >>> > > >> > >> > > >