Re:Find/Replace on a JSON Object Graph
by woan on Saturday April 23, 2011 @01:42PM
(#2477201)
I am not up on this but in XML world I would have used XPath. I see there are both JsonPath and JsonQuery gems that seem to be geared for this kind of stuff.
Re:Find/Replace on a JSON Object Graph
by darkxanthos on Saturday April 23, 2011 @03:21PM
(#2477339)
I thought they just query...? Actually, I was just prototyping this in Ruby for porting to C#... I couldn't find anything in c# to do this either. I basically have .NET objects I'm serializing out to JSON then I want to take that JSON and use what I did here and then bring it back into .NET objects. This may not be my final solution (I may opt for reflection in the end) but I want to see this solution through.
Re:Find/Replace on a JSON Object Graph
by woan on Saturday April 23, 2011 @04:32PM
(#2477526)
They return the objects meeting the criteria and you set the property blindly. The query API I saw has a clone and replace API too which is good if concurrency is a concern.
Re:Find/Replace on a JSON Object Graph
by RodgerTheGreat on Saturday April 23, 2011 @11:45AM
(#2477002)
Speaking as a non-rubyist, I notice that the last code sample features some pretty serious "pyramid building". Is the "opt out" approach not idiomatic? For comparison, I'd probably write it like this: http://pastebin.com/4P03Uqrq