woocommerce / wc-api-ruby

A Ruby wrapper for the WooCommerce API.
MIT License
69 stars 74 forks source link

Allow To Overwrite httparty default format options #35

Closed nikgoy closed 6 years ago

nikgoy commented 7 years ago

I faced a unique issue, that certain woocommerce plugins cause the HTTParty response to have a BOM character which is very troublesome and JSON.parse will cause an Unexpected Token Error The solution I came across was to pass additional parameters in JSON.parse for the HTTParty Response in plain format

JSON.parse(response.encode('utf-8', 'binary', :undef => :replace, :replace => ''))

The change allows us to change the default HTTParty format: argument to plain:, if required.

hobertro commented 7 years ago

I know you guys are busy at Woo, but just wondering if anyone is going to review this PR?