JSON-LD: "Missing ',' or ']' in array declaration." on closing </script> tag - json-ld

I am marking up a local business page using Schema.org. I am trying to apply the openingHoursSpecification value using JSON-LD syntax, but I am receiving a syntax error when I validate through SDTT.
The error is on line 67 of my code, which only has the closing </script> tag.
I have tried moving the ], on line 63 to line 66 to make sure the opens and closes value/objects are a part of the openingHoursSpecification array, but I only receive more errors. I am puzzled as to what the closing </script> tag has to do with my code.
Sample code:
{
"#context": "https://schema.org",
"#type": "LocalBusiness",
"image": "http://www.website.com/example.png",
"#id": "http://www.website.com",
"name": "ExampleBusiness",
"address": {
"#type": "PostalAddress",
"streetAddress": "xxxxxxxxxxxxxxxx",
"addressLocality": "Houston",
"addressRegion": "Texas",
"postalCode": "xxxxx",
"addressCountry": "United States"
},
"review": {
"#type": "Review",
"reviewRating": {
"#type": "Rating",
"ratingValue": "4",
"bestRating": "5"
},
"author": {
"#type": "Person",
"name": "xxxxxx"
}
},
"geo": {
"#type": "GeoCoordinates",
"latitude": xx.xx,
"longitude": -xx.xx
},
"url": "http://www.example.com",
"telephone": "+0000000000",
"openingHoursSpecification": [
{
"#type": "OpeningHoursSpecification",
"dayOfWeek": [
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday"
],
"opens": "08:00",
"closes": "17:00"
}]
Error shown in SDTT:

You open the JSON-LD with a {, but it doesn’t end with a }. So, you need to add a } to the end:
}]
}
Another error: You need to quote all string values. So, this
"latitude": xx.xx,
"longitude": -xx.xx
should be this
"latitude": "xx.xx",
"longitude": "-xx.xx"

Unless it's just a copy-paste error when posting this question, it looks like you are just missing a closing brace '}'. You are seeing the error on line 67 because it reaches the script tag while trying to parse the JSON because there is no closing brace to terminate the parser.
Should be able to just add '}'.
One site I often use to test JSON that seems malformed is https://jsonlint.com/

Related

How to Break json object in a for each

How can one split the below json example by different email in a for each loop? So the end result is two completely separate entities keeping there own objects and arrays.
This result comes from a sql dump but the sql connector alters the output, so I've had to parse that output in a for each loop of its own even though there is no loop it's all in one line.
[
{
"Email": "Steve#gmail.com",
"Name": "Steve Larson",
"ID": "1111",
"Date": "2022-09-12",
"Address": "10 Chicken Place",
"Town": "Gatebody",
"Postcode": "xxx 1xx",
"Data": [
{
"Ref": "34546",
"Transaction_Date": "2018-11-29",
"Amount": 27.76,
"Balance": 27.76,
"Notes": "Beep1"
},
{
"Ref": "34546v2",
"Transaction_Date": "2018-12-24",
"Amount": 27.76,
"Balance": 27.76,
"Notes": "Beep2"
}
]
},
{
"Email": "innis#gmail.com",
"Name": "Innis Blitz",
"ID": "3456",
"Date": "2022-10-12",
"Address": "33 Snake Road",
"Town": "March",
"Postcode": "cxc 3cd",
"Data": [
{
"Ref": "078776701",
"Transaction_Date": "2021-08-27",
"Amount": 984.68,
"Balance": 984.68,
"Notes": "Yes please"
},
{
"Ref": "078776701v2",
"Transaction_Date": "2021-08-27",
"Amount": 98422.6,
"Balance": 98432.6,
"Notes": "Please not now"
}
]
}
]
Would like to do a for each so it splits the above like so. The idea then for my to load the result of the for each into a template that takes arrays.
{
"Email": "Steve#gmail.com",
"Name": "Steve Larson",
"ID": "1111",
"Date": "2022-09-12",
"Address": "10 Chicken Place",
"Town": "Gatebody",
"Postcode": "xxx 1xx",
"Data": [
{
"Ref": "34546",
"Transaction_Date": "2018-11-29",
"Amount": 27.76,
"Balance": 27.76,
"Notes": "Beep1"
},
{
"Ref": "34546v2",
"Transaction_Date": "2018-12-24",
"Amount": 27.76,
"Balance": 27.76,
"Notes": "Beep2"
}
]
}
{
"Email": "innis#gmail.com",
"Name": "Innis Blitz",
"ID": "3456",
"Date": "2022-10-12",
"Address": "33 Snake Road",
"Town": "March",
"Postcode": "cxc 3cd",
"Data": [
{
"Ref": "078776701",
"Transaction_Date": "2021-08-27",
"Amount": 984.68,
"Balance": 984.68,
"Notes": "Yes please"
},
{
"Ref": "078776701v2",
"Transaction_Date": "2021-08-27",
"Amount": 98422.6,
"Balance": 98432.6,
"Notes": "Please not now"
}
]
}
I have reproduced in my environment and got expected results and I followed below process:
I have initialized your input as below:
Then i added for each control and send the output of previous step as input as inside of foreach loop, i have added send email action.
Outputs:
I have got tow jsons in two seperate emails as above.

Parsing Nested JSON and Manipulating It in Ruby

This is my first attempt at parsing nested JSON with Ruby. I need to go through the JSON to pull out specific values for "_id", "name", and "type" for instance. I then need to create a reference table so that I can refer to each "_id" and associated information. I also need to combine information from multiple JSON responses. I've been able to get basic information and have tried a few things I've found online. I just need a little assistance with a starting point. If anyone has any ideas of where to start with this I'd really appreciate it.
Devices JSON response hash. Each device starts with _id.
{
"api": "1.0",
"error": null,
"id": "60b5d4c3077862123cfa4443",
"result": {
"devices": [
{
"_id": "123456787786211fd31f3dd",
"batteryPowered": true,
"category": "door_lock",
"deviceTypeId": "144_1_1",
"firmware": [
{
"id": "us.144.1_1.0",
"version": "2.6"
}
],
"gatewayId": "1234567807786214fbc6bd4e",
"info": {
"firmware.stack": "3.28",
"hardware": "0",
"manufacturer": "Kwikset",
"model": "912",
"protocol": "zwave",
"zwave.node": "2",
"zwave.smartstart": "no"
},
"name": "Garage Door",
"parentDeviceId": "",
"persistent": false,
"reachable": false,
"ready": true,
"roomId": "1234567807786211fd31f3eb",
"security": "middle",
"status": "idle",
"subcategory": "",
"type": "doorlock"
},
{
"_id": "1234567897786211fd31f3ed",
"batteryPowered": true,
"category": "door_lock",
"deviceTypeId": "59_1_1129",
"firmware": [
{
"id": "us.59.18064.0",
"version": "3.3"
},
{
"id": "us.59.18065.1",
"version": "11.0"
}
],
"gatewayId": "1234567897786214fbc6bd4e",
"info": {
"firmware.stack": "6.3",
"hardware": "3",
"manufacturer": "Schlage",
"model": "BE469ZP",
"protocol": "zwave",
"zwave.node": "3",
"zwave.smartstart": "no"
},
"name": "Front Door",
"parentDeviceId": "",
"persistent": false,
"reachable": true,
"ready": true,
"roomId": "1234567807786211fd31f3ec",
"security": "high",
"status": "idle",
"subcategory": "",
"type": "doorlock"
},
{
"_id": "1234567897786211fd31f40a",
"batteryPowered": false,
"category": "switch",
"deviceTypeId": "57_20562_12344",
"firmware": [
{
"id": "us.57.29240.0",
"version": "5.25"
}
],
"gatewayId": "1234567807786214fbc6bd4e",
"info": {
"firmware.stack": "4.54",
"hardware": "255",
"manufacturer": "Honeywell",
"model": "ZW4103/39337",
"protocol": "zwave",
"zwave.node": "4",
"zwave.smartstart": "no"
},
"name": "Lamp Switch",
"parentDeviceId": "",
"persistent": false,
"reachable": true,
"ready": true,
"roomId": "1234567807786211fd31f416",
"security": "no",
"status": "idle",
"subcategory": "interior_plugin",
"type": "switch.outlet"
},
{
"_id": "1234567b07786211fd31f40e",
"batteryPowered": false,
"category": "dimmable_light",
"deviceTypeId": "57_20548_12339",
"firmware": [
{
"id": "us.57.29747.0",
"version": "5.21"
}
],
"gatewayId": "1234567d07786214fbc6bd4e",
"info": {
"firmware.stack": "4.34",
"hardware": "255",
"manufacturer": "Honeywell",
"model": "39339/ZW3107",
"protocol": "zwave",
"zwave.node": "5",
"zwave.smartstart": "no"
},
"name": "Lamp Dimmer",
"parentDeviceId": "",
"persistent": false,
"reachable": true,
"ready": true,
"roomId": "1234567807786211fd31f416",
"security": "no",
"status": "idle",
"subcategory": "dimmable_plugged",
"type": "dimmer.outlet"
}
]
}
}
There is then also a JSON response that lists the functions for each device in the same format above. However instead of "devices"=> it is "items"=> and the beach function is the _id key again.
I'd like to combine function _id tags and descriptions with the device JSON, so I can create a way to send my script "unlock door lock 1" and it subs the number with the _id of the device and the function _id.
You can start with a very rough navigator function like this:
def find_device(data, name, index)
# Filter through the device list...
data['result']['devices'].select do |device|
# ...for matching names.
device.name == name
end[index] # Take indexed entry
end
Where now you can do find_device(data, 'door_lock', 0) to dig up that entry.
Converting "door lock 1" to [ 'door_lock', 0 ] should be pretty trivial:
def to_location(str)
# Split off the name component(s) and index number
*name, index = str.split(/\s+/)
# Reassemble with underscores and -1 to account for 0-index
[ name.join('_'), index.to_i - 1 ]
end

JSON-LD Missing '}' or object member name. Syntax error: value, object or array expected. How to solved this

I tried adding this job posting SD to my HTML I keep getting this
What am I getting wrong
<script type="application/ld+json"> [
{
"#context": "http://schema.org/",
"#type": "JobPosting",
"title": "Job1",
"description": "",
"datePosted": "2018-10-26",
"validThrough": "2018-11-02",
"hiringOrganization": {
"#type": "Place",
"address": {
}
}
},
{
"#context": "http://schema.org/",
"#type": "JobPosting",
"title": "Job2",
"description": "",
"datePosted": "2018-10-26",
"validThrough": "2018-11-02",
"hiringOrganization": {
"#type": "Place",
"address": {
}
}
}
] </script>
I got this two messages from structured data, how do I fix it

Wrong expansion of JSON-LD

I'm learning to work with JSON-LD and I'm stuck on this problem. This is mine document...
{
"#context": {
"dbr": "http://dbpedia.org/resource/",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"italy": "dbr:Italy_national_football_team",
"ita_player_base_url": "italy:/",
"foaf": "http://xmlns.com/foaf/0.1/",
"team": "foaf:Organization",
"player": "foaf:Person",
"player_of": {
"#id": "foaf:member",
"#type": "#id"
},
"plays_with": {
"#id": "foaf:knows",
"#type": "#id"
},
"name": {
"#id": "foaf:name",
"#type": "xsd:string"
},
"number": {
"#id": "foaf:status",
"#type": "xsd:positiveInteger"
}
},
"#graph": [{
"name": "Buffon",
"number": "1",
"#type": "player",
"player_of": "italy",
"#id": "ita_player_base_url:Buffon"
}, {
"name": "Insigne",
"number": "20",
"#type": "player",
"player_of": "italy",
"#id": "ita_player_base_url:Insigne",
"plays_with": "ita_player_base_url:Buffon"
}]}
Then if I paste it to a JSON-LD to GIF service (or to everything else) I get that the players are "player_of":"domainOfTheValidator/italy" instead of "player_of":"http://dbpedia.org/resource/Italy_national_football_team"
Why is this happening? Obviously if I put "player_of": "dbr:Italy_national_football_team" instead of "player_of": "italy" it works... I'm getting crazy.
A compact IRI consists of a prefix, followed by :, followed by a suffix.
With "italy": "dbr:Italy_national_football_team" you are defining the prefix (italy). When you want to use it in a value, you have to use the colon (:) followed by a suffix (which is empty in your case).
So instead of
"player_of": "italy",
you would have to use
"player_of": "italy:",

Google Glass Timeline Item with NAVIGATE action is not showing up on Glass device

Why doesn't a timeline item with this payload offer the turn by turn navigation options from Google Glass, is there a bug ? If the answer is because it needs more properties set that sucks to make us call another endpoint.
{
"kind": "mirror#timelineItem",
"id": "035cb808-a908-4057-914f-f980fb35c620",
"bundleId": "12",
"created": "2013-08-21T22:52:54.635Z",
"updated": "2013-08-21T22:52:54.635Z",
"etag": "\"hzfI85yu0lKQdtWV4PO1jAbQxWw/UvNo_kKkfbIjHfhmNjOLyMSNIeA\"",
"creator": {
"kind": "mirror#contact",
"source": "api:34091916267",
"id": "70",
"displayName": "Monica Wilkinson"
},
"title": "glass-4",
"text": "...",
"html": "....",
"speakableText": "...",
"location": {
"kind": "mirror#location",
"latitude": 37.7657774,
"longitude": -122.4075774,
"displayName": "Crushpath Labs"
},
"menuItems": [
{
"action": "NAVIGATE"
}
]
}
Try this:
"location": {
"latitude": 37.7657774,
"longitude": -122.4075774,
"accuracy": 36.0
},
It works for me.

Resources