Announcement

Collapse
No announcement yet.

populateFromArray an bug for case JSON_ARRAY

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • populateFromArray an bug for case JSON_ARRAY

    Hi.

    case self::JSON_ARRAY:
    $value = is_string($value) ? json_decode($value) : $value;
    if (!is_array($value)) {
    $value = null;
    }
    break;

    By default json_decode alway return an Object if the second parameter not special. So in this case I think the code should be:


    case self::JSON_ARRAY:
    $value = is_string($value) ? json_decode($value, true) : $value;
    if (!is_array($value)) {
    $value = null;
    }
    break;

  • #2
    Hi

    It's not a bug. It returns array of stdClass object as designed.

    JSON_ARRAY - array of objects
    JSON_OBJECT - object

    Comment


    • #3
      Originally posted by yurikuzn View Post
      Hi

      It's not a bug. It returns array of stdClass object as designed.

      JSON_ARRAY - array of objects
      JSON_OBJECT - object
      I don't think so. The access element is not same in both cases. So when someone want to use JSON_ARRAY. It should be return an Array not array of objects.

      Comment


      • #4
        That's because you used to php arrays. Array is not a hash table. I'm designer of EspoCRM and I know better how it works. Your suggestion will be a disaster because it will cause a lot of issues. I don't have spare time to discuss this.
        Last edited by yuri; 09-04-2015, 09:49 AM.

        Comment

        Working...
        X