Sri
Sri

Reputation: 1217

JSON to JSON-LD (+ Schema.org) conversion

Following is an example JSON data that I get in JS Ajax call request. How can I transform this into JSON-LD and append to head tag?

   [
    {
    "resort": "100",
    "resortCategory": "BEST",
    "resortDistanceMiles": 37.1,
    "resortDistanceKms": 59.7,
    "currencySymbol": "$",
    "resortAvailable": "AVAILABLE",
    "resortSummary": {
      "resort": "19100",
      "latitude": 29.460099,
      "longitude": -90.321457,
      "timeZone": "America/New_York",
      "name": "Best Western Isabelle Court",
      "description": "Welcome to other!",
      "address1": "17026 Highway 3235",
      "city": "Galliano",
      "phoneNumber": "+1 985-325-3800",
      "faxNumber": "985/325-3808",
      "postalCode": "70354",
      "stateCode": "LA",
      "state": "Louisiana",
      "countryCode": "US",
      "country": "United States",
      "currencyCode": "USD",
      "currencyDescription": "U.S. DOLLARS",
      "resortCategory": "BEST",
      "checkOutNoticeTime": "11:00 a.m.",
      "checkInNoticeTime": "3:00 p.m.",
      "propertyType": "INTOWN",
      "prearrivalEmail": true
    },
    "searchableAmenities": [
      {
        "text": "Air Conditioning at property",
        "attributeValueCode": "AIR CONDITIONING"
      },
      {
        "text": "AIR CONDITIONED",
        "attributeValueCode": "AIRCON"
      },
      {
        "text": "AM/FM alarm clock",
        "attributeValueCode": "ALRMCK"
      },
      {
        "text": "Beach on premises or nearby",
        "attributeValueCode": "BEACH"
      },
      {
        "text": "Best Western",
        "attributeValueCode": "BEST WESTERN"
      },
      {
        "text": "Complimentary Breakfast",
        "attributeValueCode": "BRKFST COMP"
      },
      {
        "text": "Business center on premises (fax/copier/computer etc)",
        "attributeValueCode": "BUSCTR"
      },
      {
        "text": "Cable or satellite TV on premises.",
        "attributeValueCode": "CABLE TV"
      },
      {
        "text": "Guests that are 12 years old and younger are considered children.",
        "attributeValueCode": "CHILD 12"
      },
      {
        "text": "Coffee makers available in room.",
        "attributeValueCode": "COFFEE MAKERS"
      },
      {
        "text": "RJ-11 Modular/dataports phone jacks available in room.",
        "attributeValueCode": "DATA PORT"
      },
      {
        "text": "24 hour front desk",
        "attributeValueCode": "DESK24"
      },
      {
        "text": "Physically challenged facilities available",
        "attributeValueCode": "DISABL"
      },
      {
        "text": "Property has elevator access to floors.",
        "attributeValueCode": "ELEVATOR"
      },
      {
        "text": "Express checkout available",
        "attributeValueCode": "EXCKOT"
      },
      {
        "text": "Exercise facilities available on premises.",
        "attributeValueCode": "EXERCISE"
      },
      {
        "text": "Free parking available.",
        "attributeValueCode": "FPRKNG"
      },
      {
        "text": "Free local telephone calls",
        "attributeValueCode": "FRCLLS"
      },
      {
        "text": "Free Breakfast Offered at Property",
        "attributeValueCode": "FREE BREAKFAST"
      },
      {
        "text": "Free continental breakfast - Includes juice, bread or sweet roll, and coffee.",
        "attributeValueCode": "FREE CONT. BRKFST"
      },
      {
        "text": "All Guest Rooms are Hardwired or Wireless",
        "attributeValueCode": "FRWL-HW-GUESTRM"
      },
      {
        "text": "Free Wireless in Public Areas and Guest Rooms",
        "attributeValueCode": "FRWL-PUBGUEST"
      },
      {
        "text": "In-room hair dryers.",
        "attributeValueCode": "HAIR DRYERS"
      },
      {
        "text": "High Speed Internet Access",
        "attributeValueCode": "HIGH SPEED"
      },
      {
        "text": "Higher rates may apply for special events and holidays.",
        "attributeValueCode": "HOLIDAY/EVENT RATES"
      },
      {
        "text": "Inside Corridors",
        "attributeValueCode": "INSIDE-CORR"
      },
      {
        "text": "Irons and ironing boards available in room.",
        "attributeValueCode": "IRONS/IRONING BOARDS"
      },
      {
        "text": "Microwave oven in room.",
        "attributeValueCode": "MICROWAVE"
      },
      {
        "text": "Multi-lingual staff.",
        "attributeValueCode": "MULTI-LINGUAL"
      },
      {
        "text": "No pets allowed.",
        "attributeValueCode": "NO PETS"
      },
      {
        "text": "Non-smoking rooms are available.",
        "attributeValueCode": "NO SMOKING"
      },
      {
        "text": "Property entirely non-smoking",
        "attributeValueCode": "NONSMOKING"
      },
      {
        "text": "Packages are available.",
        "attributeValueCode": "PACKAGE"
      },
      {
        "text": "Refrigerators in rooms.",
        "attributeValueCode": "REFRIGERATORS"
      },
      {
        "text": "Suites at property with active rates",
        "attributeValueCode": "SUITES"
      }
    ],
    "resortSearchRate": {
      "resortRatePlan": "RACK",
      "resortRateCode": "RACK",
      "totalAmount": 129,
      "resortRoomCategory": "2290273"
    },
    "tripAdvisor": {
      "resort": "19100",
      "medianUserRating": 4.0,
      "reviewCount": 90,
      "tripAdvisorId": 578901
    },
    "resortRestriction": ""
       }
    ]

Upvotes: 1

Views: 658

Answers (1)

unor
unor

Reputation: 96587

You have to map your properties to Schema.org properties.

Your data seems to be about a resort, so you could use the Resort type. This type page lists all properties a Resort can have in Schema.org.

For example, your searchableAmenities could be mapped to Schema.org’s amenityFeature, where each value has the type LocationFeatureSpecification.

For relevant properties that can’t be mapped (as Schema.org doesn’t have properties for every case), you can make use of additionalProperty.

With mapping, there are two ways:

  • You could either publish all of your data using your own vocabulary, and only use the Schema.org vocabulary where the mapping is possible.
  • Or you could only use the Schema.org vocabulary and omit the data that can’t be mapped.

Upvotes: 2

Related Questions