On Wednesday, January 30, 2019 at 4:36:29 AM UTC-5, fugee ohu wrote: > > > > On Wednesday, January 30, 2019 at 2:02:06 AM UTC-5, Colin Law wrote: >> >> >> >> On Wed, 30 Jan 2019, 03:52 fugee ohu <fuge...@gmail.com wrote: >> >>> >>> >>> On Tuesday, January 29, 2019 at 4:21:43 AM UTC-5, Colin Law wrote: >>>> >>>> On Tue, 29 Jan 2019 at 03:20, fugee ohu <fuge...@gmail.com> wrote: >>>> > ... >>>> > Can you give me an idea how to extract it >>>> >>>> Are you seriously asking, after the years that you have been using >>>> Ruby, that you don't know how to extract a particular section from a >>>> string? Apart from anything else, since I haven't got access to the >>>> full string (nor do I want it), I have no idea what the details >>>> surrounding the JSON section are so can't tell you how to do it. >>>> >>>> Colin >>>> >>> >>> It looks like this: >>> >>> /**/jQuery18308525223902976695_1548819829968({"success":true,"code":0,"results":[{"productId":32755997022,"sellerId":201591356,"oriMinPrice":"US >>> >>> $275.00 ... }); >>> >>> JSON.parse and cxt.eval both return errors even if I remove everything >>> up to the first { and then chomp the trailing ) >>> >> >> Have you checked that the trailing } you show there is the one that >> matches the { you show? Perhaps there is more than one JSON string there. >> If you have checked that then show us where the error occurs. Presumably >> you have already looked at that though and have not found what I suggest. >> >> Colin >> >> >> >> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Ruby on Rails: Talk" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to rubyonrails-ta...@googlegroups.com. >>> To post to this group, send email to rubyonra...@googlegroups.com. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/rubyonrails-talk/9783f3a7-4739-4de9-8a44-a4c4900d0c8c%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/rubyonrails-talk/9783f3a7-4739-4de9-8a44-a4c4900d0c8c%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> > parsed_obj=JSON.parse( res.body.gsub(/^.+\(/,"").chomp(");") ) > puts parsed_obj > > that gets me => true > > > I can print the outer values of parsed_obj with an iteration loop parsed_obj.each |key, val| do can you tell me how do i select individual keys within the nested hash 'results'
-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c3cd0d1e-aaf5-4fe8-9732-ac1454f6fe58%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.