So i have this json file:
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"name": "space-rocket-blocks/hero",
"version": "0.1.0",
"title": "Hero",
"category": "space-rocket-blocks",
"icon": "smiley",
"description": "For when you need a hero",
"supports": {
"html": false
},
"textdomain": "hero",
"editorScript": "file:./index.js",
"editorStyle": "file:./index.css",
"style": "file:./style-index.css"
}
i tried following other stackoverflow questions without succes, so i hoped one of you might spot the problem
but i have to add this information:
{
"attributes": {
"headingContent": {
"type": "string",
"source": "text",
"selector": "h1",
"default": "How to build custom React Gutenberg Blocks"
},
"textContent": {
"type": "string",
"source": "text",
"selector": "p",
"default": "Anim aute id magna aliqua ad ad non deserunt sunt. Qui irure qui lorem cupidatat commodo. Elit sunt amet fugiat veniam occaecat fugiat aliqua."
},
},
}
but i cannot add this information, whatever i tried. it keeps returning errors.
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"name": "space-rocket-blocks/hero",
"version": "0.1.0",
"title": "Hero",
"category": "space-rocket-blocks",
"icon": "smiley",
"description": "For when you need a hero",
"supports": {
"html": false
},
"textdomain": "hero",
"editorScript": "file:./index.js",
"editorStyle": "file:./index.css",
"style": "file:./style-index.css"
}
{
"attributes": {
"headingContent": {
"type": "string",
"source": "text",
"selector": "h1",
"default": "How to build custom React Gutenberg Blocks"
},
"textContent": {
"type": "string",
"source": "text",
"selector": "p",
"default": "Anim aute id magna aliqua ad ad non deserunt sunt. Qui irure qui lorem cupidatat commodo. Elit sunt amet fugiat veniam occaecat fugiat aliqua."
},
},
}
this returns: 'End of file expected. json [Ln23, col1]'. (on the opening bracket above "attributes"
CodePudding user response:
It seems like you have 2 JSON objects as parents in the same file.JSON file only can have one parent that. You can have both in a single parent
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 2,
"name": "space-rocket-blocks/hero",
"version": "0.1.0",
"title": "Hero",
"category": "space-rocket-blocks",
"icon": "smiley",
"description": "For when you need a hero",
"supports": {
"html": false
},
"textdomain": "hero",
"editorScript": "file:./index.js",
"editorStyle": "file:./index.css",
"style": "file:./style-index.css"
"attributes": {
"headingContent": {
"type": "string",
"source": "text",
"selector": "h1",
"default": "How to build custom React Gutenberg Blocks"
},
"textContent": {
"type": "string",
"source": "text",
"selector": "p",
"default": "Anim aute id magna aliqua ad ad non deserunt sunt. Qui irure qui lorem cupidatat commodo. Elit sunt amet fugiat veniam occaecat fugiat aliqua."
},
},
}