json-machine icon indicating copy to clipboard operation
json-machine copied to clipboard

Unexpected symbol with Items::fromStream

Open andus4n opened this issue 1 year ago • 2 comments

Hi. I have a weird issue with this library...maybe i'm doing something wrong, but in short:

  • i'm downloading a large json file with CURLOPT_FILE set to php://temp (w+)
  • pointer set to "/items"
  • when using Items::fromStream() i'm getting an error (Unexpected symbol 'L"},{"image":"https' At position 0)

If i change my logic and use a file (created with tmpfile()) instead of php://temp everything works fine (in this case i'm using Items::fromFile(stream_get_meta_data($handler)['uri])

Any idea?

andus4n avatar May 12 '23 22:05 andus4n

Please provide the full php code and at least a part of the json file to reproduce this. It might also be that the json is actually corrupted. Try enabling debug mode and check the position in json file where it crashes.

halaxa avatar May 13 '23 16:05 halaxa

sure, i'm attaching a overly-simplified emulated version of the code and the "*.json" file as well. also, i'm attaching two screenshots with de working/not-working versions. I have to mention, that the "fromStream" version would work if i'd get rid of the validation block.

error ok project.zip

andus4n avatar May 13 '23 19:05 andus4n