I'm trying to put together a JobPosting that has multiple locations listed. In the Structured Data Type Definitions listed on the developers.google.com site, it says:
If the job has multiple locations, add multiple jobLocation properties in an array. Google will choose the best location to display based on the job seeker's query.
But I continue to get an error:
"jobLocation":[
{
"#type":"Place",
"address":{
"#type":"PostalAddress",
"streetAddress":"1366 N Mockingbird Ln.",
"addressLocality":"Abilene",
"addressRegion":"TX",
"postalCode": "79603",
}
}
{
"#type":"Place",
"address":{
"#type":"PostalAddress",
"streetAddress":"3301 South 1st Street",
"addressLocality":"Abilene",
"addressRegion":"TX",
"postalCode": "79603"
}
}
]
Missing '}' or object member name.
The item that is highlighted is the first closing bracket after the first postalCode.
Remove the comma in "postalCode": "79603",, and add a comma to separate the items in the array:
"jobLocation": [
{},
{}
]
I think you need a comma after the ] - here is how it worked for me:
"jobLocation": [
{
"#type": "Place",
"address": {
"#type": "PostalAddress",
"streetAddress": "XYZ",
"addressLocality": "XYZ",
"postalCode": "XYZ",
"addressCountry": "DE"
}
},
{
"#type": "Place",
"address": {
"#type": "PostalAddress",
"streetAddress": " XYZ",
"addressLocality": "XYZ",
"postalCode": "XYZ",
"addressCountry": "DE"
}
}
],
Related
I have to extract attributes from a json file that I receive from an api call using InvokeHTTPCustom. JSON FILE has the following sample data :
[
{
"input_index": 0,
"candidate_index": 0,
"delivery_line_1": "1 Santa Claus Ln",
"last_line": "North Pole AK 99705-9901",
"delivery_point_barcode": "997059901010",
"components": {
"primary_number": "1",
"street_name": "Santa Claus",
"street_suffix": "Ln",
"city_name": "North Pole",
"state_abbreviation": "AK",
"zipcode": "99705",
"plus4_code": "9901",
"delivery_point": "01",
"delivery_point_check_digit": "0"
},
"metadata": {
"record_type": "S",
"zip_type": "Standard",
"county_fips": "02090",
"county_name": "Fairbanks North Star",
"carrier_route": "C004",
"congressional_district": "AL",
"rdi": "Commercial",
"elot_sequence": "0001",
"elot_sort": "A",
"latitude": 64.75233,
"longitude": -147.35297,
"coordinate_license": 1,
"precision": "Rooftop",
"time_zone": "Alaska",
"utc_offset": -9,
"dst": true
},
"analysis": {
"dpv_match_code": "Y",
"dpv_footnotes": "AABB",
"dpv_cmra": "N",
"dpv_vacant": "N",
"dpv_no_stat": "Y",
"active": "Y",
"footnotes": "L#"
}
},
{
"input_index": 1,
"candidate_index": 0,
"addressee": "Apple Inc",
"delivery_line_1": "1 Infinite Loop",
// truncated for brevity
}
]
I have extracted all the required data such as address, state, city, primary_number, etc.
However, when I try to extract latitude,longitude from metadata, it leads to failure in EvaluateJsonPathAttributeCustom processor. Other attributes, which are in string format, get extracted correctly. However, this being not a string, might be issue, is my diagnosis.
How do I get this working?
I need to extract longitudes and latitudes.
Please give detail explanation as I am new to nifi.
Configuration in nifi for EvaluateJsonPathAttributeCustom:
Attribute Name Input : x**.json
Attribute Name Output : latitude
JsonPathExpresssion : $[0].metadata.latitude
Splitif.. : False
One way to do this is by using the JOLT https://jolt-demo.appspot.com/.
I would recommend using the JoltTransformJSON NiFi Processor as it can really help make things easy to pull out only the data that you want. I have tried your specific request and it will work to pull out those data. You can configure JOLT to pull any data you require and it might be easier once you get the hang of it.
[{
"operation": "shift",
"spec": {
"*": {
"metadata": {
"latitude": "latitude",
"longitude": "longitude"
}
}
}
}]
I'm using the following JSON to produce a review snippet:
<script type="application/ld+json">
{
"#context": "https://schema.org/",
"#type": "Review",
"name": "Great service from the start.",
"author": {
"#type": "Person",
"name": "Chris Tonich"
},
"reviewBody": "Very thorough...would highly recommend!",
"aggregateRating": {
"#type": "AggregateRating",
"ratingValue": "4.9",
"bestRating": "5",
"ratingCount": "110",
"itemReviewed": {
"#type": "Product",
"image": "https://www.homeintegrity.com.au/wp-content/uploads/2020/12/hi-new-logo2.jpg",
"name": "Pre-Purchase Building Inspections",
"priceRange": "$$",
"telephone": "08 8375 8130",
"address" :{
"#type": "PostalAddress",
"streetAddress": "PO Box 163",
"addressLocality": "Scarborough",
"addressRegion": "WA",
"postalCode": "6019",
"addressCountry": "AU"
}
}
}
}
</script>
The Google Rich Snippet Test says:
Why am I receiving the error when the Review contains aggregateRating which contains itemReviewed?
Why does it say I rated a Review rather than an Item?
Help appreciated.
Your structure is not according to the schema found on https://schema.org/
A Review must contain a field itemReviewed (or be embedded in the object, which is reviewed). (see examples at https://schema.org/Review)
A Review on the other hand must not contain an AggregateRating (see https://schema.org/AggregateRating), because an AggreateRating may only be a sub-node of a Brand, CreativeWork, Event, Offer, Organization, Place, Product, or Service. Note that these types may contain a Review too.
Your structure roughly is as follows:
Review "Great service from the start."
Author "Chris Tonich"
Aggregate rating "4.9"
Product "Pre-Purchase Building Inspections"
Address "6019 - ..."
What you probably want is something along the lines of:
LocalBusiness "Pre-Purchase Building Inspections"
Address "6019 - ..."
Review "Great service from the start."
Author "Chris Tonich"
Aggregate rating "4.9"
I am setting up schema for rating stars to show up on google search results, I got this json script, It does not have any error when I test the code snippet, But shows an error :
Missing '}' or object member name.
<script type=application/ld+json>{
"#context": "https://schema.org/",
"#type": "Review",
"itemReviewed": {
"#type": "LocalBusiness",
"image": "https://www.rmsdrill.com/wp-content/uploads/2019/01/RMS-Logo-header.png",
"name": "Rms Drill",</p>
<p> "telephone": "(800) 605-1608",
"address" :{
"#type": "PostalAddress",</p>
<p> "addressLocality": "Dallas",
"addressRegion": "TX",
"postalCode": "75219",
"addressCountry": "US"
}
},
"reviewRating": {
"#type": "Rating",
"ratingValue": "4"
},
"name": "Working with Rober Strunks.",
"author": {
"#type": "Person",
"name": "Dr. Jason Kihle"
},
"reviewBody": "After just one season of working with Robert Strunks, it is absolutely clear that he is everything that you want in a professional marching band drill designer. In addition…",
"publisher": {
"#type": "Organization",
"name": "RMS Drill"
}
}</script>
In the future, use this: https://jsonformatter.curiousconcept.com/
{
"#context":"https://schema.org/",
"#type":"Review",
"itemReviewed":{
"#type":"LocalBusiness",
"image":"https://www.rmsdrill.com/wp-content/uploads/2019/01/RMS-Logo-header.png",
"name":"Rms Drill",
"telephone":"(800) 605-1608",
"address":{
"#type":"PostalAddress",
"addressLocality":"Dallas",
"addressRegion":"TX",
"postalCode":"75219",
"addressCountry":"US"
}
},
"reviewRating":{
"#type":"Rating",
"ratingValue":"4"
},
"name":"Working with Rober Strunks.",
"author":{
"#type":"Person",
"name":"Dr. Jason Kihle"
},
"reviewBody":"After just one season of working with Robert Strunks, it is absolutely clear that he is everything that you want in a professional marching band drill designer. In addition…",
"publisher":{
"#type":"Organization",
"name":"RMS Drill"
}
}
There is an items node in the specifications which says it is for an array of items, like paging items, youtube video list
What if I have GET request on a single item, how should the response be formatted ?
Just to one item in the array?
items:[item]
https://google.github.io/styleguide/jsoncstyleguide.xml
I don't think #tanmay_vijay's answer is correct or nuanced enough as it seems that single item responses are in arrays in the YouTube example in the docs.
{
"apiVersion": "2.0",
"data": {
"updated": "2010-02-04T19:29:54.001Z",
"totalItems": 6741,
"startIndex": 1,
"itemsPerPage": 1,
"items": [
{
"id": "BGODurRfVv4",
"uploaded": "2009-11-17T20:10:06.000Z",
"updated": "2010-02-04T06:25:57.000Z",
"uploader": "docchat",
"category": "Animals",
"title": "From service dog to SURFice dog",
"description": "Surf dog Ricochets inspirational video ...",
"tags": [
"Surf dog",
"dog surfing",
"dog",
"golden retriever",
],
"thumbnail": {
"default": "https://i.ytimg.com/vi/BGODurRfVv4/default.jpg",
"hqDefault": "https://i.ytimg.com/vi/BGODurRfVv4/hqdefault.jpg"
},
"player": {
"default": "https://www.youtube.com/watch?v=BGODurRfVv4&feature=youtube_gdata",
"mobile": "https://m.youtube.com/details?v=BGODurRfVv4"
},
"content": {
"1": "rtsp://v5.cache6.c.youtube.com/CiILENy73wIaGQn-Vl-0uoNjBBMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp",
"5": "https://www.youtube.com/v/BGODurRfVv4?f=videos&app=youtube_gdata",
"6": "rtsp://v7.cache7.c.youtube.com/CiILENy73wIaGQn-Vl-0uoNjBBMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp"
},
"duration": 315,
"rating": 4.96,
"ratingCount": 2043,
"viewCount": 1781691,
"favoriteCount": 3363,
"commentCount": 1007,
"commentsAllowed": true
}
]
}
}
It could however be that it depends on the resource being targeted from the request. This is the way it is in the competing JSONAPI standard.
From JSONAPI standard:
A logical collection of resources MUST be represented as an array, even if it only contains one item or is empty.
You don't need to have items field for showing single item. If you're sure your API is always going to return single object, you can return it as data itself.
{
"data": {
"kind": "user",
"fields": "author,id",
"id": "bart",
"author": "Bart"
}
}
Fields such as data.kind data.fields data.etag data.id data.lang data.updated data.deleted can still be used here.
Source for snippet docs
Consider a JSON representation for delivering a package from one address to another. Simplified,
{
"parcelId": 123,
"source": {
"street": "123 Main Street",
"city": "Anytown",
"state": "New York"
},
"destination": {
"street": "456 Avenue B",
"city": "Elsewhere",
"state": "New Jersey"
}
}
I'm fairly sure that keys "street", "city", and "state" can be legally nested in both "source" and "destination" objects. Are there technical reasons that the key names should not be repeated?
Are there technical reasons that the key names should not be repeated?
No. Seems perfectly reasonable to me.
e.g. if I was serialising a Scala/Java object, that object could look like:
class Delivery {
val parcelId : String
val source : Address
val destination : Address
}
and the field names of the Address object would be the same here.
There is nothing wrong with having duplicate property keys which are part of different objects in JSON.
Your JSON example is perfectly valid.
This is only an issue when they are at the same level.
For example two source objects:
{
"parcelId": 123,
"source": {
"street": "123 Main Street",
"city": "Anytown",
"state": "New York"
},
"source": {
"street": "456 Avenue B",
"city": "Elsewhere",
"state": "New Jersey"
}
}
Or two street properties inside one object:
"source": {
"street": "456 Avenue B",
"street": "Elsewhere",
"state": "New Jersey"
}
No. This would be confusing if you had delivery.street and then a different delivery.street. But you don't. You have delivery.source.street and delivery.destination.street. Basically the key street is addressing a completely different object now.