If I had a JSON file that had multiple objects, can the method read through without some form of exception?

  • 1
    \$\begingroup\$ Have you considered trying it? \$\endgroup\$
    – user35344
    Commented Jan 29, 2019 at 13:29
  • \$\begingroup\$ As Tyyppi_77 says, this is something you can answer much faster for yourself by just making a multi-object JSON file and trying to parse it. Does the data come through as expected? Or does it throw an Exception? Boom, you have your answer - no internet hearsay required. :) \$\endgroup\$
    – DMGregory
    Commented Jan 29, 2019 at 13:40
  • \$\begingroup\$ @DMGregory Alright, sorry about that. \$\endgroup\$ Commented Jan 29, 2019 at 22:01

1 Answer 1


It looks like the implementation of parse_json calls JSON::parse. JSON::parse looks like a fairly generic JSON parsing routine, but it does expect the top-level of the JSON fed to it to be a single value (since defers, once, to _parse_value).

Thus, it looks like you can provide it JSON containing multiple objects within a top-level array or structure. But if you provide it a string that happens to contain two independent sets of JSON, it will only parse the first one.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .