Ruby on Rails
Wednesday, January 30, 2019
On Wednesday, January 30, 2019 at 12:44:53 PM UTC-5, Colin Law wrote:
On Wed, 30 Jan 2019 at 16:41, fugee ohu <fuge...@gmail.com> wrote:
>
>
>
> On Wednesday, January 30, 2019 at 9:45:03 AM UTC-5, Colin Law wrote:
>>
>> On Wed, 30 Jan 2019 at 13:48, fugee ohu <fuge...@gmail.com> wrote:
>> >
>> >>
>> >> Show us what puts parsed_obj["results"] gives. If it is long then
>> >> from the start up to where productID occurs.
>> >>
>> >> Colin
>> >
>> >
>> > {"productId"=>32970292001, "sellerId"=>235696817, "oriMinPrice"=>"US $50.00", "oriMaxPrice"=>"US $50.00", "productTitle"=>"Paid function", "minPrice"=>"US $50.00", "maxPrice"=>"US $50.00", "orders"=>"1", "productImage"=>"//ae01.alicdn.com/kf/ ", "productDetailUrl"=>" ...HTB10AX7aPLuK1Rjy0Fhq6xpdFXa5. jpg
>>
>> Are you absolutely sure that is what parsed_obj["results"] is?
>> Frankly I think you are mistaken.
>> Looking at the original source you posted which had
>> "results":[{"productId":32755997022,"...
>> suggests that actually parsed_obj["results"] should be
>> [ {"productId"=>32970292001,...},{...}]
>>
>> Colin
>
>
> Unparsed response looks like this
> /**/myscript.js({"success":true,"code":0,"results":[{" productId":32962770119, ... ,"itemEvalTotalNum":0}]," finished":false,"page":1," pageSize":20,"postback":" 9954eca0-4297-4d1f-bada- a5c3b131214c","pin":"gps-id= pcDetailLeftTrendProduct&scm= 1007.13438.100207.0&scm_id= 1007.13438.100207.0&scm-url= 1007.13438.100207.0&pvid= 778c79a8-9092-483e-92cb- f393856b0565"});
> So if I'm gonna use this approach I have to gsub out everything up to the first [{ after the last }]
> As you can see I was trying another approach as well, need to learn both, substituting the original callback script for myscript.js I can write a function instead of using JSON.parse but I wanna be able to do it both ways
Am I right in saying that parsed_obj is actually an array as I
suggested? If so then do you not know how to access the elements of
the array?
Colin
Everything in the unparsed resonse body that I want is between [ and ] I have to gsub it out
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+unsubscribe@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/cdbd3db4-a36c-4c0e-8684-553937a9e74f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment