Hi all,
I've searched for an answer on this but couldn't find anything definitive.
Using Automate.io, I have a Google Sheet successfully receiving data from a OnePage webhook when a deal is created. The following is a sample of the data being received...
{:id=>"5c486fc01787fa4517d31d13", :contact_id=>"5bdc64061787fa14ea8392b2", :owner_id=>"59391112c5a1f8d208e26024", :owner=>{:id=>"59391112c5a1f8d208e26024", :name=>"Dave Turner", :email=>"hello@epicbeers.co.uk"}, :name=>"DK", :text=>"1 x Wash Gold\n1 x Pilcrow\n1 x Red India", :date=>"2019-01-23", :contact_info=>{:contact_name=>"", :company=>"David Turner (BS24)"}, :author=>"Dave T.", :amount=>3.0, :months=>1, :total_amount=>3.0, :cost=>0.0, :total_cost=>0.0, :margin=>3.0, :commission=>0.0, :commission_percentage=>0.0, :commission_type=>"none", :commission_base=>"amount", :status=>"won", :has_related_notes=>false, :attachments=>[], :deal_fields=>[{:deal_field=>{:id=>"5aab7603aa7620144c5aa813", :name=>"Deliver WC", :type=>"date", :position=>0}, :value=>"2019-01-28"}], :has_deal_items=>false, :deal_items=>[], :created_at=>"2019-01-23T13:44:32Z", :modified_at=>"2019-01-23T13:44:34Z", :close_date=>"2019-01-23"}
I need to now parse this with a Google script and wasn't having much luck (I'm very new to JSON too by the way), so pasted the info in to jsonlint.com to check the data and it returns an error...
Error: Parse error on line 1:
{: id => "5c486fc0178
-^
Expecting 'STRING', '}', got ':'
It says it may be down to an extra comma at the end of a list but I don't think there is.
As a result, I can't seem to use the JSON.parse function in my script to get at the info.
Anyone know what I'm missing here please?
Hugely big thanks in advance
Dave
Hi Dave!
Thank you for your feedback and sorry for delayed response.
This data you received is a string representation of a ruby hash object with keys as ruby symbols. It looks like a bug on our side. But we can't fix it right away, because we have many customers using our webhooks API and this change can break their integrations.
First of all we have to find those customers which use it and we'll ask them if this change/fix can break their code. If there aren't many customers who use it, we can declare current implementation as deprecated and then fix this issue in a while. Otherwise we will have to implement a side API with fixed JSON object in order to leave current customers' integrations intact. But hopefully our customers will be okay with the fix in the current API.
Well, I don't know what our customers do with the JSON object you've mentioned, because you're the first who reported this bug. But I'd like to advise you in your case: given JSON will be parsed successfully if you find all entries of ":{some_string}=>" substrings and replace it with "{some_string}:" before giving the data to JSON parser. This can be done using regexps: you find all entries with /:(\w+)=>/ regexp and then replace found entry with "{matched word}" + ':', so at the end you'll get a valid JSON string which can be successfully parsed by JSON parser
Vladimir
Thanks Vladimir, appreciate the reply and your suggestion. I've done something similar to your suggestion now so I can get the info I need, thanks ever so much and good luck with any fixes!