PHP SDK 3.1 always decodes JSON objects to array instead of expected stdClass

documents are stored in JSON object format:

 "address": {
    "address1": null,
    "city": null,
    "county": null,
    "state": null,
    "zip": null
  }

but are being returned by the SDK incorrectly decoded into arrays (instead of the expected stdClass objects)

[address] => Array <--- wrong, should be stdClass
        (
            [address1] => 
            [city] => 
            [county] => 
            [state] => FL
            [zip] => 
        )

I expect the return type of JSON objects to be stdClass, NOT array.

This worked as expected in previous version 2.x of the PHP SDK.

Tried updating php.ini with a mysterious flag I had to hunt down elsewhere:

[couchbase]
couchbase.decoder.json_arrays = 0 //`false`, as shown in the documentation, does nothing and does not set this

My guess is that this setting is now completely ignored by the 3.1 SDK (if it was ever respected at all).

Documentation states that the default behavior of the decoder is to create stdClass, but again, this is not true.

HELP!

This issue is fixed on master branch, and will be released as 3.1.2 soon.

1 Like