Numeric and Boolean values are rendered as strings in JSON-LD output

Created on 27 December 2024, 4 months ago

Problem/Motivation

When using the Schema.org Metatag module to generate JSON-LD, numeric fields (such as width and height) and Boolean values (e.g., representativeOfPage) are rendered with quotes. For example, "3596" instead of 3596, and "TRUE" instead of true.

Although Google generally still parses these values correctly, having them as strings does not align with JSON-LD best practices and can potentially cause issues with other parsers or structured data validators.

Steps to reproduce

Install and enable Schema.org Metatag.
Configure a Product (or any other entity) with numeric/Boolean fields (e.g., width, height, representativeOfPage).
Inspect the generated JSON-LD.

Expected behavior
Numeric fields and Boolean values should be rendered as proper JSON numbers and booleans (e.g., 3596 without quotes, and true instead of "TRUE").

Actual behavior
Numeric fields and Boolean values are wrapped in quotes, making them strings.

Proposed resolution

Output numeric and Boolean fields as their respective JSON data types rather than strings.

Thank you for considering this request. It would help ensure that the generated structured data follows JSON-LD best practices and possibly avoid parsing issues in some scenarios.

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Active

Version

3.0

Component

Code

Created by

🇦🇹Austria gr4phic3r

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024