OK,I found I lost,thank you!I forget that I have used workitem['fields']['address'] style.
On Tue, May 18, 2010 at 8:37 PM, John Mettraux <[email protected]>wrote: > > On Tue, May 18, 2010 at 05:26:53AM -0700, hansen wang wrote: > > > > I want to get the fields information from a workitem > > eg: > > { "_rev":0, > > "put_at":"2010-05-14 09:50:41.505516 UTC", > > "participant_name":"requestor", > > "wfid":"20100514-bimakeroni", > > "_id":"wi!0_0_0_0!!20100514-bimakeroni", > > "fields": > > {"address":"[email protected]", > > "dispatched_at":"2010-05-14 09:50:41.502761 UTC", > > "params": > > {"task":"upload_account_application_form", > > "ref":"requestor" > > }, > > "object_id":17, > > "object_type":"email" > > }, > > "type":"workitems", > > "fei": > > {"sub_wfid":null, > > "wfid":"20100514-bimakeroni", > > "engine_id":"engine", > > "expid":"0_0_0_0" > > } > > } > > > > in this file ,I want to get > > 'address','task,'ref','object_id','object_type' information. I try to > > use JSON.parser(workitem) > > but I'm fail. > > Hello, > > at first a piece of advice, it would be easier for you to ask the workitem > via the StorageParticipant. > > I have the impression you are doing something wrong. > > Now, I will reply anyway. > > you can do > > ---8<--- > workitem = Ruote::Workitem.new(Rufus::Json.decode(workitem)) > > address = workitem.fields['address'] > task = workitem.fields['params']['task'] > ref = workitem.fields['params']['ref'] > object_id = workitem.fields['object_id'] > object_type = workitem.fields['object_type'] > --->8--- > > you could also do > > ---8<--- > workitem = Rufus::Json.decode(workitem) > > address = workitem['fields']['address'] > task = workitem['fields']['params']['task'] > ref = workitem['fields']['params']['ref'] > object_id = workitem['fields']['object_id'] > object_type = workitem['fields']['object_type'] > --->8--- > > Be warned once again : I don't where you get this string of JSON from, but > you're probably misunderstanding something. > > > Best regards, > > -- > John Mettraux - http://jmettraux.wordpress.com > > -- > you received this message because you are subscribed to the "ruote users" > group. > to post : send email to [email protected] > to unsubscribe : send email to > [email protected]<openwferu-users%[email protected]> > more options : http://groups.google.com/group/openwferu-users?hl=en > -- you received this message because you are subscribed to the "ruote users" group. to post : send email to [email protected] to unsubscribe : send email to [email protected] more options : http://groups.google.com/group/openwferu-users?hl=en
