I am using an API which requires I send it data as new line delimited JSON, for example;
{"id":"67523", "name":"Jason"}
{"id":"69928", "name":"Doug"}
The API accepts single JSON objects, but can accept multiple new line delimited JSON objects in a single batch (more efficient). How do you construct string objects like the above in PHP?
If taking a string like {"id":"67523", "name":"Jason"}
, I can json_decode()
it to turn it into an associative array (this is accepted by the API endpoint). However, the only way I can see to pass a number of these objects together is within an array, but the API does not accept an array of JSON objects.