• Hi all. I have a trouble with theme.json file in block theme. I received a notice: PHP Notice: Error when decoding a JSON file at path bla-bla – theme.json. I checked it by json checkers, but all ok, PhpStorm don’t give syntax errors. How to fix it or check it to find a error?

    {
    "$schema": "https://schemas.wp.org/trunk/theme.json",
    "version": "2",
    "settings": {
    "appearanceTools": true,
    "color": {
    "palette": [
    {
    "color": "#ffffff",
    "name": "Base",
    "slug": "base"
    },
    {
    "color": "#000000",
    "name": "Contrast",
    "slug": "contrast"
    },
    {
    "color": "#9DFF20",
    "name": "Primary",
    "slug": "primary"
    },
    {
    "color": "#F6F6F6",
    "name": "Tertiary",
    "slug": "tertiary"
    }
    ]
    },
    "layout": {
    "contentSize": "650px",
    "wideSize": "1200px"
    },
    "spacing": {
    "spacingScale": {
    "steps": 0
    },
    "spacingSizes": [
    {
    "size": "clamp(1.5rem, 5vw, 2rem)",
    "slug": "30",
    "name": "1"
    },
    {
    "size": "clamp(1.8rem, 1.8rem + ((1vw - 0.48rem) * 2.885), 3rem)",
    "slug": "40",
    "name": "2"
    },
    {
    "size": "clamp(2.5rem, 8vw, 4.5rem)",
    "slug": "50",
    "name": "3"
    },
    {
    "size": "clamp(3.75rem, 10vw, 7rem)",
    "slug": "60",
    "name": "4"
    },
    {
    "size": "clamp(5rem, 5.25rem + ((1vw - 0.48rem) * 9.096), 8rem)",
    "slug": "70",
    "name": "5"
    },
    {
    "size": "clamp(7rem, 14vw, 11rem)",
    "slug": "80",
    "name": "6"
    }
    ],
    "units": [
    "%",
    "px",
    "em",
    "rem",
    "vh",
    "vw"
    ]
    },
    "typography": {
    "dropCap": false,
    "fluid": true,
    "fontFamilies": [
    {
    "fontFace": [
    {
    "fontFamily": "DM Sans",
    "fontStretch": "normal",
    "fontStyle": "normal",
    "fontWeight": "400",
    "src": [
    "file:./assets/fonts/dm-sans/DMSans-Regular.woff2"
    ]
    },
    {
    "fontFamily": "DM Sans",
    "fontStretch": "normal",
    "fontStyle": "italic",
    "fontWeight": "400",
    "src": [
    "file:./assets/fonts/dm-sans/DMSans-Regular-Italic.woff2"
    ]
    },
    {
    "fontFamily": "DM Sans",
    "fontStretch": "normal",
    "fontStyle": "normal",
    "fontWeight": "700",
    "src": [
    "file:./assets/fonts/dm-sans/DMSans-Bold.woff2"
    ]
    },
    {
    "fontFamily": "DM Sans",
    "fontStretch": "normal",
    "fontStyle": "italic",
    "fontWeight": "700",
    "src": [
    "file:./assets/fonts/dm-sans/DMSans-Bold-Italic.woff2"
    ]
    }
    ],
    "fontFamily": "\"DM Sans\", sans-serif",
    "name": "DM Sans",
    "slug": "dm-sans"
    },
    {
    "fontFace": [
    {
    "fontDisplay": "block",
    "fontFamily": "IBM Plex Mono",
    "fontStretch": "normal",
    "fontStyle": "normal",
    "fontWeight": "300",
    "src": [
    "file:./assets/fonts/ibm-plex-mono/IBMPlexMono-Light.woff2"
    ]
    },
    {
    "fontDisplay": "block",
    "fontFamily": "IBM Plex Mono",
    "fontStretch": "normal",
    "fontStyle": "normal",
    "fontWeight": "400",
    "src": [
    "file:./assets/fonts/ibm-plex-mono/IBMPlexMono-Regular.woff2"
    ]
    },
    {
    "fontDisplay": "block",
    "fontFamily": "IBM Plex Mono",
    "fontStretch": "normal",
    "fontStyle": "italic",
    "fontWeight": "400",
    "src": [
    "file:./assets/fonts/ibm-plex-mono/IBMPlexMono-Italic.woff2"
    ]
    },
    {
    "fontDisplay": "block",
    "fontFamily": "IBM Plex Mono",
    "fontStretch": "normal",
    "fontStyle": "normal",
    "fontWeight": "700",
    "src": [
    "file:./assets/fonts/ibm-plex-mono/IBMPlexMono-Bold.woff2"
    ]
    }
    ],
    "fontFamily": "'IBM Plex Mono', monospace",
    "name": "IBM Plex Mono",
    "slug": "ibm-plex-mono"
    },
    {
    "fontFace": [
    {
    "fontFamily": "Inter",
    "fontStretch": "normal",
    "fontStyle": "normal",
    "fontWeight": "200 900",
    "src": [
    "file:./assets/fonts/inter/Inter-VariableFont_slnt,wght.ttf"
    ]
    }
    ],
    "fontFamily": "\"Inter\", sans-serif",
    "name": "Inter",
    "slug": "inter"
    },
    {
    "fontFamily": "-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen-Sans,Ubuntu,Cantarell,\"Helvetica Neue\",sans-serif",
    "name": "System Font",
    "slug": "system-font"
    },
    {
    "fontFace": [
    {
    "fontFamily": "Source Serif Pro",
    "fontStretch": "normal",
    "fontStyle": "normal",
    "fontWeight": "200 900",
    "src": [
    "file:./assets/fonts/source-serif-pro/SourceSerif4Variable-Roman.ttf.woff2"
    ]
    },
    {
    "fontFamily": "Source Serif Pro",
    "fontStretch": "normal",
    "fontStyle": "italic",
    "fontWeight": "200 900",
    "src": [
    "file:./assets/fonts/source-serif-pro/SourceSerif4Variable-Italic.ttf.woff2"
    ]
    }
    ],
    "fontFamily": "\"Source Serif Pro\", serif",
    "name": "Source Serif Pro",
    "slug": "source-serif-pro"
    }
    ],
    "fontSizes": [
    {
    "fluid": {
    "min": "0.875rem",
    "max": "1rem"
    },
    "size": "1rem",
    "slug": "small"
    },
    {
    "fluid": {
    "min": "1rem",
    "max": "1.125rem"
    },
    "size": "1.125rem",
    "slug": "medium"
    },
    {
    "fluid": {
    "min": "1.75rem",
    "max": "1.875rem"
    },
    "size": "1.75rem",
    "slug": "large"
    },
    {
    "fluid": false,
    "size": "2.25rem",
    "slug": "x-large"
    },
    {
    "fluid": {
    "min": "4rem",
    "max": "10rem"
    },
    "size": "10rem",
    "slug": "xx-large"
    }
    ]
    },
    "useRootPaddingAwareAlignments": true
    },
    "styles": {
    "blocks": {
    "core/navigation": {
    "spacing": {
    "blockGap": "40rem"
    },
    "elements": {
    "link": {
    ":hover": {
    "typography": {
    "textDecoration": "underline"
    }
    },
    ":focus": {
    "typography": {
    "textDecoration": "underline dashed"
    }
    },
    ":active": {
    "typography": {
    "textDecoration": "none"
    }
    },
    "typography": {
    "textDecoration": "none"
    }
    }
    },
    "typography": {
    "fontSize": "18px",
    "fontFamily": "Futura PT",
    "fontStyle": "normal",
    "fontWeight": "400",
    "lineHeight": "normal"
    }
    },
    "core/site-title": {
    "elements": {
    "link": {
    ":hover": {
    "typography": {
    "textDecoration": "underline"
    }
    },
    ":focus": {
    "typography": {
    "textDecoration": "underline dashed"
    }
    },
    ":active": {
    "color": {
    "text": "var(--wp--preset--color--secondary)"
    },
    "typography": {
    "textDecoration": "none"
    }
    },
    "typography": {
    "textDecoration": "none"
    }
    }
    },
    "typography": {
    "fontSize": "var(--wp--preset--font-size--medium)",
    "fontWeight": "normal",
    "lineHeight": "1.4"
    }
    }
    },
    "color": {
    "background": "var(--wp--preset--color--base)",
    "text": "var(--wp--preset--color--contrast)"
    },
    "elements": {
    "button": {
    "border": {
    "radius": "0"
    },
    "color": {
    "background": "var(--wp--preset--color--primary)",
    "text": "var(--wp--preset--color--contrast)"
    },
    ":hover": {
    "color": {
    "background": "var(--wp--preset--color--contrast)",
    "text": "var(--wp--preset--color--base)"
    }
    },
    ":focus": {
    "color": {
    "background": "var(--wp--preset--color--contrast)",
    "text": "var(--wp--preset--color--base)"
    }
    },
    ":active": {
    "color": {
    "background": "var(--wp--preset--color--secondary)",
    "text": "var(--wp--preset--color--base)"
    }
    },
    ":visited": {
    "color": {
    "text": "var(--wp--preset--color--contrast)"
    }
    }
    },
    "h1": {
    "typography": {
    "fontSize": "3.625rem",
    "lineHeight": "1.2"
    }
    },
    "h2": {
    "typography": {
    "fontSize": "clamp(2.625rem, calc(2.625rem + ((1vw - 0.48rem) * 8.4135)), 3.25rem)",
    "lineHeight": "1.2"
    }
    },
    "h3": {
    "typography": {
    "fontSize": "var(--wp--preset--font-size--x-large)"
    }
    },
    "h4": {
    "typography": {
    "fontSize": "var(--wp--preset--font-size--large)"
    }
    },
    "h5": {
    "typography": {
    "fontSize": "var(--wp--preset--font-size--medium)",
    "fontWeight": "700",
    "textTransform": "uppercase"
    }
    },
    "h6": {
    "typography": {
    "fontSize": "var(--wp--preset--font-size--medium)",
    "textTransform": "uppercase"
    }
    },
    "heading": {
    "typography": {
    "fontWeight": "400",
    "lineHeight": "1.4"
    }
    },
    "link": {
    "color": {
    "text": "var(--wp--preset--color--contrast)"
    },
    ":hover": {
    "typography": {
    "textDecoration": "none"
    }
    },
    ":focus": {
    "typography": {
    "textDecoration": "underline dashed"
    }
    },
    ":active": {
    "color": {
    "text": "var(--wp--preset--color--secondary)"
    },
    "typography": {
    "textDecoration": "none"
    }
    },
    "typography": {
    "textDecoration": "underline"
    }
    }
    },
    "spacing": {
    "blockGap": "1.5rem",
    "padding": {
    "top": "var(--wp--preset--spacing--40)",
    "right": "var(--wp--preset--spacing--30)",
    "bottom": "var(--wp--preset--spacing--40)",
    "left": "var(--wp--preset--spacing--30)"
    }
    },
    "typography": {
    "fontFamily": "var(--wp--preset--font-family--system-font)",
    "fontSize": "var(--wp--preset--font-size--medium)",
    "lineHeight": "1.6"
    }
    },
    "templateParts": [
    {
    "area": "header",
    "name": "header",
    "title": "Header"
    },
    {
    "area": "footer",
    "name": "footer",
    "title": "Footer"
    }
    ]
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @parambala

    I copied the contents you shared and pasted it into https://jsonlint.com/ It is reported as valid JSON.

    I also created a theme.json file with those contents in the folder of a test theme. Then, loaded the front-end of my test site and the editors. Everything works correctly.

    Can you share a bit more about the steps for you to get the errors?

    Best,
    André

    Thread Starter parambala

    (@parambala)

    Thank you! I think trouble may associated with my local environment. I’ll try to check it.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Troubles with theme.json’ is closed to new replies.