JsonFeed: Unexpected control character found
Issue #3132300 on drupal.org by goyote.
Good afternoon,
I have setup a migrate import job, but "drush migrate:import restaurant
" returns an error "Passed variable is not an array or object"
I found the error was from below file.
In migrate_plus\src\Plugin\migrate_plus\data_parser\Json.php line 101:Passed variable is not an array or object
protected function openSourceUrl($url) {
// (Re)open the provided URL.
$source_data = $this->getSourceData($url);
$this->iterator = new \ArrayIterator($source_data); //line 101
return TRUE;
}
From getSourceData function above in the same json.php file, I found json_decode returns an error "Unexpected control character found"
$source_data = json_decode($response, TRUE); returns null
json_last_error() // this returns 3 JSON_ERROR_CTRL_CHAR: Unexpected control character found';
+++++++++++++++++++ My Migrate settings +++++++++++
id: restaurant
label: restaurant json
migration_group: json group # description
source:
plugin: url
data_fetcher_plugin: http
data_parser_plugin: json
urls: 'http://xxx/1.json'
item_selector: products
+++++++++++++++++++ My Json file +++++++++++
{
"status": 0,
"numberOfResults": 33,
"queryTime": 1,
"products": [
{
"productId": "XXXXX",
"productNumber": "XXXXX",
"status": "ACTIVE",
"productUpdateDate": "2020-03-30T23:01:57.811+10:00",
"owningOrganisationId": "XXXXX",
"owningOrganisationNumber": "XXXXX",
"owningOrganisationName": "XXXXX",
"productName": "Aboriginal Fine Arts Gallery",
"productDescription": "XXXXX, XXXXX. XXXXX\r\n\r\nXXXXX",
"productCategoryId": "ATTRACTION",
"productImage": "https://XXXXX/images/XXXXX.jpeg?rect=0,0,2048,1536&w=280&h=210&rot=360",
"boundary": "-XXXXX.XXXXX,XXXXX.XXXXX",
"addresses": [
{
"address_type": "XXXXX",
"address_line": "XXXXX, XXXXX",
"address_line2": "XXXXX",
"city": "XXXXX",
"state": "XXXXX",
"postcode": "XXXXX",
"country": "XXXXX",
"area": ["XXXXX"],
"region": ["XXXXX"]
}],
"score": 1,
"productPixelURL": "http://XXXXX/pixel?productId=XXXXX&distributorId=XXXXX&language=en"
}]
}