Schema bug – numeric values output as strings in JSON-LD
-
Hi Rank Math team,
I’d like to report what appears to be a schema output issue.
I found a couple of cases where numeric schema values seem to be created correctly at first, but in the final JSON-LD output they are converted into strings instead of remaining numbers.
Examples from live output:
BreadcrumbList.itemListElement[].positionbecomes"1"instead of1ImageObject.width/heightbecome"512"instead of512
From testing and tracing the plugin code, the issue seems to happen in the final schema rendering pipeline:
includes/modules/schema/snippets/class-breadcrumbs.php– breadcrumbpositionappears to be created as an integerincludes/modules/schema/class-jsonld.php– the final graph appears to be passed throughwp_kses_post_deep()beforewp_json_encode()
Based on testing, that final step seems to convert numeric values into strings before the JSON-LD is printed. I only confirmed this in a couple of numeric fields, but it may be affecting other numeric values in the schema output as well.
It may be worth checking whether the final sanitization step in
includes/modules/schema/class-jsonld.phppreserves numeric values instead of converting them into strings before output.Thanks for taking a look.
You must be logged in to reply to this topic.