what characters are allowed in google search structured data

693 views Asked by At

I want to use google rich search results with structured data.

I'm confused about what characters the description tag can take.

For example, I want to use

{ description: "this is a backslash \ here" }

I know JSON does not allow a backslash without escaping

My question is if I replace the \ with \u005C' like this

{ description: "this is a backslash \u005C here" }

Will this display \ on the rendered page or will it display '\u005C'

1

There are 1 answers

0
Tony McCreath On BEST ANSWER

Google will parse the data using the json rules so will most likely see it as a backslash.

A way to get an idea is to run a comment like this in your browsers console.

console.log({ description: "this is a backslash \u005C here" });

This also results in the backslash:

console.log({ description: "this is a backslash \\ here" });

Google does do its own post processing of the strings it sees. e.g. it will most likely remove any html and some emojis.

And sometimes even Google has a bug in the way they encode/decode that can cause strange outputs.

The only way to know for certain is to test. But I think you will be fine as in this case the encoding is dealt with via json.