I have a json file like this
{
"online": false,
"key": "123",
"Product": {
"name": "product name",
"Id": 12,
},
}
I have my json migration file
source:
plugin: url
data_fetcher_plugin: file
data_parser_plugin: json
urls:
- 'json_path/data.json'
item_selector: /Product
fields:
- name: keyword
label: 'Keyword'
selector: name
ids:
product_key:
type: string
constants:
vocabulary: tag
process:
vid: constants/vocabulary
name: keyword
destination:
plugin: entity:taxonomy_term
but I am getting the following error.
Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null
It means the xpath is not correct.
I have tried with the item_selector: $
and for the keyword selector selector: Product.name
but then I am getting this error.
Passed variable is not an array or object
I have tried with item_selector: 0
and item_selector: /
but nothing worked.
However when I use the following json.
{
"online": false,
"key": "123",
"Product": [
{
"name": "product name",
"Id": 12,
}
],
}
Notice the [] brackets.
What is the issue? How can I make it work without the [] brackets because I don't have any control on the json to change it.