not production ready

Clean Schema



Step 1. Embed The Script Tag

The implement this code resource, simply and paste this code onto your website:

Step 2. Set Attributes

Set Script Tag Attributes

No items found.

Set Element Attributes

No items found.
Throughout the schema framework utilization, an additional key called "_requiredKeys" is often utilized.This key is not recognized in the vocabulary or by any search engines. This key holds an array of key names used in the same schema object. For example: When generating schema markup dynamically (using variables to populate values), the variables used in the JSON template are not always present. This results an empty value, in a key-value pairing.If the template is set up, such that a value in a key-value pair is only a single variable, and that variable is non-existent, it can cause a JSON syntax error, and prevent the rest of the schema markup code template from being constructed.This JavaScript code snippet solves this problem.Running a JSON through this function will return back the same JSON input with both the keys and the values for empty key-value pairs removed.This helps in:Resolving JSON syntax errorsMaintaining clean JSON codeIncreasing JSON parse speed Input data can cause recursive object generation.A "Person" object might have the attribute "worksFor".The "worksFor" attribute might nest the object type "Organization".The "Organization" object might have the attribute "employees".The "employees" attribute might nest that original "Person" object.And so on, and so on...‍This function detects, and prevents this.‍This function removes these deeply nested recursive objects, and replaces them with their "@id" equivalent, only as deeply as needed to properly articulate the existing object / sub-object relationship.Here is an example of recursive mention: And the following is the cleaned code (note an @id is held in place of the continually recursive objects). This maintains cyclical reference while minimizing code:



If you're comfortable with JavaScript, you can add (and potentially alter) the following code directly on your website.

More Code Resources

See All Code Resources