Forum Moderators: coopster

Message Too Old, No Replies

JSON Validation

Trying to verify this JSON is coded correctly

         

Propools

4:21 pm on Jan 13, 2022 (gmt 0)

10+ Year Member



We use an outside source for the back end coding of our site. They are quite reliable and smart as a whip. Great team of people. Recently our Schema was switched to JSON and I'm not sure it's coded correctly. Would someone mind checking this and advise? Thanks. So, as not to promote our site, I am using "example.com" as a domain name.
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "Product",
"name": "Coronado 24&#39; Round Resin Hybrid Above Ground Pool with Standard Package | 54&quot; Wall | 59658",
"image": [
"https://www.example.com/Products/Large/59658_0_201752911953.jpg"
],
"description": "Bigger, Better, Stronger, Longer. This is the fortitude of the CaliMar® Coronado model 24&#39; round pool with standard package.",
"sku": "59658",
"mpn": "*-Coronado-Kit",
"gtin": "651658955633",
"brand": {
"@type": "Brand",
"name": "CaliMar"
},
"offers": {
"@type": "Offer",
"url": "https://www.example.com/product/coronado-24-round-resin-hybrid-above-ground-pool-with-standard-package54-wall59658/59658",
"priceCurrency": "USD",
"price": "4282.94",
"priceValidUntil": "2023-1-13",
"itemCondition": "https://schema.org/NewCondition",
"availability": "https://schema.org/InStock"
}
}
</script>

The "itemCondition" and "availability" are my biggest concerns.

For the value "priceValidUntil", does that mean that the price is valid until that date or through the end of that date?

NickMNS

5:05 pm on Jan 13, 2022 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



For the value "priceValidUntil", does that mean that the price is valid until that date or through the end of that date?

JSON stands for JavaScript Object Notation, it is merely a way to structure data and says nothing about the data. To answer your question you need to ask the provider of the data.

As to determining whether the "encoding" is correct. You can simply use in Javascript, the command JSON.stringify() to convert your data to a JSON string, and then use JSON.parse() to convert the string to an Object. If neither of those steps throws an error, then your mostly good. But you still need to check that the resulting Object has the key:value pairs as you are expecting.

I don't code in PHP so I don't know what convenience packages exist for JSON, but I know that in Python and other languages they exist. So you can use such a package in the PHP environment to dynamically check, create or read the JSON data. I would not recommend parsing the data yourself, while it is not difficult there are always edge cases that can cause you problems when you least expect them.

NickMNS

5:06 pm on Jan 13, 2022 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Here is some more info about JSON and the various JS commands:
[developer.mozilla.org...]
[developer.mozilla.org...]
[developer.mozilla.org...]