Cloud Stack Ninja

I am trying to read a JSON file that contains an array of objects located in laravel storage and trying to iterate it. My attempt is as below.

$json = Storage::disk('local')->get('users.json');
json_decode($json, true);

This will return string type for the $json. So I cannot iterate. Anyone knows where I got wrong and how can I fix it?

Below is the part of my $json output.

[
  {
    "_id": 1,
    "url": "http://initech.tokoin.io.com/api/v2/users/1.json",
    "external_id": "74341f74-9c79-49d5-9611-87ef9b6eb75f",
    "name": "Francisca Rasmussen",
    "alias": "Miss Coffey",
    "created_at": "2016-04-15T05:19:46 -10:00",
    "active": true,
    "verified": true,
    "shared": false,
    "locale": "en-AU",
    "timezone": "Sri Lanka",
    "last_login_at": "2013-08-04T01:03:27 -10:00",
    "email": "coffeyrasmussen@flotonic.com",
    "phone": "8335-422-718",
    "signature": "Don't Worry Be Happy!",
    "organization_id": 119,
    "tags": [
      "Springville",
      "Sutton",
      "Hartsville/Hartley",
      "Diaperville"
    ],
    "suspended": true,
    "role": "admin"
  },
  {...}
]

unsupported utf8 characters included in the file is the issue.



Read more here: https://stackoverflow.com/questions/64410469/read-a-json-file-and-iterate-in-php

Content Attribution

This content was originally published by M.Cooper at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: