On Sat, 29 Dec 2018, 03:42 fugee ohu <fugee...@gmail.com wrote:

>
>
> On Friday, December 28, 2018 at 5:00:46 PM UTC-5, Colin Law wrote:
>>
>> On Fri, 28 Dec 2018 at 21:40, fugee ohu <fuge...@gmail.com> wrote:
>> > ...
>> > I think I just need to strip the leading
>> /**/jQuery18307882633047005491_1545805999753 from the result
>>  
>> /**/jQuery18307882633047005491_1545805999753({"success":true,"code":0,"results":[{"productId":32817749905,
>>
>> > Anyone can help with the regex?
>>
>> If you can't work out the regex just find the position of the first {
>> and strip to there.
>>
>> Colin
>>
>
> I gsub'd for the first  ({
>
>  json_data = res.body.gsub(/^.+\(\{/, "\(\{")
> json = JSON.parse(json_data)
> JSON::ParserError: 765: unexpected token at
> '({"success":true,"code":0,"results":[{"productId":32817
>


Look at the JSON spec again. What should the first char be?

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-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/007843ea-8793-46fb-ab40-bf63e55fb2bf%40googlegroups.com
> <https://groups.google.com/d/msgid/rubyonrails-talk/007843ea-8793-46fb-ab40-bf63e55fb2bf%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAL%3D0gLvz6K0_DXCwGBfupqKsVLeZH3P81KuYJTyBDM9BZjXH3g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to