Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add json config option to utilize output_format parameter #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MateuszWilk
Copy link

No description provided.

@loicsapone
Copy link
Member

Hi,

Thanks for your contribution !

I have a problem with your pull request. Your parseJSON function returns a null response because of the substr. By removing it, it works.
Is the substr function necessary ?

@MateuszWilk
Copy link
Author

I was getting a UTF-8 BOM formatted JSON string from prestashop webservice which was returning null from json_decode. The substring was the only way I found to make it return an associative array. What version of prestashop are You using? (mine was 1.6.1.11)

@loicsapone
Copy link
Member

I'm using Prestashop 1.6.1.11 too.

What are your URL path and query and what does $request['response'] return ?
Here is mine (indented) response :

{  
    "products":[  
        {  
            "id":1,
            "id_manufacturer":"1",
            "id_supplier":"1",
            "id_category_default":"5",
            "new":null,
            "cache_default_attribute":"1",
            "id_default_image":"1",
            "id_default_combination":"1",
            "id_tax_rules_group":"1",
            "position_in_category":"0",
            "manufacturer_name":"Fashion Manufacturer",
            "quantity":"0",
            "type":"simple",
            "id_shop_default":"1",
            "reference":"demo_1",
            "supplier_reference":"",
            ...

@MateuszWilk
Copy link
Author

Her is my indented $request['response']:

{
   "products":[
      {
         "id":2,
         "id_manufacturer":"1",
         "id_supplier":"1",
         "id_category_default":"2",
         "new":null,
         "cache_default_attribute":"7",
         "id_default_image":"25",
         "id_default_combination":"7",
         "id_tax_rules_group":"1",
         "position_in_category":"1",
         "manufacturer_name":"Fashion Manufacturer",
         "quantity":"0",
         "type":"simple",
         "id_shop_default":"1",
         "reference":"demo_2",
         "supplier_reference":"",
         ...

And as the string looks OK when I do a bin2hex on the string and the $request['response'] there is a 6 char length difference. This are the first values of both 'bin2hex' results:

plain string = "7b2270726..."
$request['response'] = "efbbbf7b2270726..."

As You can see the response has a prepended 6 chars which are efbbbf.

@loicsapone
Copy link
Member

That's strange because these 6 hex chars correspond to 3 ASCII chars (ï, » and ¿) that does not appear in your JSON result and I don't have these chars in my $request['response']...
Maybe the problem come from your server. On which machine is running your prestashop and your Symfony2 project (OS, version, *AMP) ?

@MateuszWilk
Copy link
Author

Server:

Red Hat 4.4.6-4
Apache/2.4.25
MySQL 5.6.27
PHP 5.6.30

Local:

macOS 10.12
nginx/1.10.2
MySQL 5.7.16
PHP 5.6.29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants