Parsed JSON in multiple columns - sql

I'm working on some API info collecting and I've written a program that reads the domains and looks up the API info and after it finds the info it puts the whole JSON text it made into a column in Microsoft SQL server table.
This is how one of the JSON output looks:
{
"id": "3e3562a7-b160-4fd8-a190-8ca0a5288794",
"name": "Garmin",
"legalName": "Garmin Ltd.",
"domain": "garmin.com",
"domainAliases": [
"garmin.de",
"garmin.se",
"garmin.si",
"garmin.nl",
"garmin.dk",
"garmin.it",
"garmin.fi",
"garmin.no",
"garmin.hr",
"garmin.at",
"garmin.pl",
"garmin.cl",
"garmin.com.au",
"garmin.co.uk",
"garmin.be",
"garminconnect.com",
"garmin.com.mx",
"garminservice.de",
"garmin.es",
"garminasus.com",
"garminonline.de",
"opencaching.com",
"garmin.com.br",
"garmin.pt",
"garminfrance.com",
"garmin.ro",
"garmin.com.hr",
"garmin.com.ar",
"garmin.ca",
"inreachdelorme.com"
],
"site": {
"title": "Garmin International | Home",
"h1": "NEW VIRBĀ® 360",
"metaDescription": "Delivering innovative GPS technology across diverse markets, including aviation, marine, fitness, outdoor recreation, tracking and mobile apps.",
"metaAuthor": "Garmin",
"phoneNumbers": [
"+1 913-397-8200"
],
"emailAddresses": [
"domain.admin#garmin.com",
"productsupport.privacy#garmin.com",
"webmaster#garmin.com",
"garminsecurity#garmin.com",
"copyright#garmin.com"
]
},
"category": {
"sector": "Information Technology",
"industryGroup": "Software & Services",
"industry": "Internet Software & Services",
"subIndustry": "Internet Software & Services",
"sicCode": "3812",
"naicsCode": null
},
"tags": [
"Technology",
"E-commerce",
"Enterprise",
"B2B",
"B2C",
"Consumer Discretionary",
"Consumer Electronics"
],
"description": "Delivering innovative GPS technology across diverse markets, including aviation, marine, fitness, outdoor recreation, tracking and mobile apps.",
"foundedYear": 1989,
"location": "Olathe, KS 66062, USA",
"timeZone": "America/Chicago",
"utcOffset": -5,
"geo": {
"streetNumber": null,
"streetName": null,
"subPremise": null,
"city": "Olathe",
"postalCode": "66062",
"state": "Kansas",
"stateCode": "KS",
"country": "United States",
"countryCode": "US",
"lat": 38.8271089,
"lng": -94.7898731
},
"logo": "https://logo.clearbit.com/garmin.com",
"facebook": {
"handle": "garmin",
"likes": 1542748
},
"linkedin": {
"handle": "company/garmin-international"
},
"twitter": {
"handle": "Garmin",
"id": "15324722",
"followers": 136976,
"following": 812,
"location": "at Garmin HQ just outside KC",
},
"crunchbase": {
"handle": "organization/garmin"
},
"emailProvider": false,
"type": "public",
"ticker": "GRMN",
"phone": "+41 52 630 16 00",
"metrics": {
"alexaUsRank": 1094,
"alexaGlobalRank": 1535,
"googleRank": null,
"employees": 10000,
"employeesRange": "1000+",
"marketCap": 9800000000,
"raised": null,
"annualRevenue": 3018665000,
"fiscalYearEnd": 12
},
"indexedAt": "2017-07-06T02:54:05.626Z",
"tech": [
"centos",
"akamai_dns",
"apache",
"outlook",
"microsoft_office_365",
"google_analytics",
"microsoft_exchange_online",
"debian",
"tealium",
"youtube",
"recaptcha"
],
"similarDomains": [
"cerner.com",
"delorme.com",
"fitbit.com",
"google.com",
"gpscity.com",
"lowrance.com",
"magellangps.com",
"novatel.com",
"polar.com",
"suunto.com",
"thegpsstore.com",
"trimble.com"
]
}
Picture example:
So what I need to do now is take only some of the data out like "Company name", "category" (with all sub-category info), "employees", "employeesrange", "marketcap", "annnualrevenue" and "similardomains" (this one should go as a full text column) and sort each one in its own column. I would be very happy for any help or directions I can get.

Using JSON_VALUE function you can extract all data from your JSON column
SELECT * ,
JSON_VALUE(JsonColumn,'$.name') AS CompanyName
, JSON_VALUE(JsonColumn,'$.category.sector') AS CategorySector
, JSON_VALUE(JsonColumn, '$.category.industryGroup') AS CategoryIndustryGroup
-- etc
FROM YourTable

Related

[Xero][Quote] Can not store tracking category option for quote line item

I have the issue when creating or updating the Quote. I can not set TrackingCategory options for line items. I request api like document but it not success.
The Tracking Category I have
tracking category
Here is my expected:
my expected
Please help me
Thanks you
Here is format payload for lineItems
"LineItems": [
{
"AccountCode": "200",
"Description": "Development work - developer onsite per day",
"UnitAmount": 650.0000,
"DiscountRate": 10.00,
"LineAmount": 585.00,
"ItemCode": "DevD",
"Quantity": 1.0000,
"TaxAmount": 58.50,
"TaxType": "OUTPUT",
"Tracking": [
{
"Name": "Location",
"Option": "Foo Bar"
}
]
}
],

Access value of variant object in shopify

I have Object of the product please check below. can you please let me know that how can I get the variants value. I have tried to get variant.inventory_quantity but can not get
{
"id": 9129131982,
"title": "Universal Suction Base Adapter",
"handle": "usb-universal-suction-base-adapter",
"description": "\u003cp\u003eAll F-Machines are supplied with a Vac-u-Lock style adapter as standard, which are compatible with Doc Johnson Vac-u-Lock dildos and toys.\u003c\/p\u003e\n\u003cp\u003eF-Machine brings you the brand new Universal Suction Base (USB). This revolutionary bolt on system integrates your favourite suction (\/flared) base sex toys with either your F-Machine Pro II or Gigolo. With this fantastic innovation from the pervy engineers at F-Machine, you can now choose which style of toy to use on your machine and discover new possibilities for sexual play \u0026amp; fantasy.\u003c\/p\u003e\n\u003cul\u003e\n\u003cli\u003eDesigned to fit all F-Machine 10 mm thrust rods\u003c\/li\u003e\n\u003cli\u003eInjection moulded from shatter proof plastic composite material\u003c\/li\u003e\n\u003cli\u003eOver-moulded brass threaded insert for maximum durability and holding capacity\u003c\/li\u003e\n\u003cli\u003eOption of dildo retention via suction, O-rings or Velcro straps (or combination)\u003c\/li\u003e\n\u003cli\u003eFits dildos with suction base diameter up to 88 mm (when installed)\u003c\/li\u003e\n\u003cli\u003eSupplied with a comprehensive O-ring set and range of Velcro straps to fit most dildo sizes\u003c\/li\u003e\n\u003cli\u003eCan be used with Double Trouble\u003c\/li\u003e\n\u003c\/ul\u003e\n\u003cp\u003e\u003cstrong\u003ePlease note:\u003c\/strong\u003e F-Machine fucking machine and toys are not included (for illustration purposes only).\u003c\/p\u003e\n\u003cp\u003e \u003c\/p\u003e",
"published_at": "2016-11-25T16:29:00-11:00",
"created_at": "2016-11-25T16:36:50-11:00",
"vendor": "F-Machine",
"type": "",
"tags": [],
"price": 4900,
"price_min": 4900,
"price_max": 4900,
"available": true,
"price_varies": false,
"compare_at_price": null,
"compare_at_price_min": 0,
"compare_at_price_max": 0,
"compare_at_price_varies": false,
"variants": [{
"id": 31980207054,
"title": "Default Title",
"option1": "Default Title",
"option2": null,
"option3": null,
"sku": "",
"requires_shipping": true,
"taxable": true,
"featured_image": null,
"available": true,
"name": "Universal Suction Base Adapter",
"public_title": null,
"options": ["Default Title"],
"price": 4900,
"weight": 600,
"compare_at_price": null,
"inventory_quantity": 2,
"inventory_management": "shopify",
"inventory_policy": "deny",
"barcode": ""
}],
inventory_quantity was deprecated recently. Instead, you'll have to use:
https://help.shopify.com/en/api/reference/inventory/inventorylevel

Get specific fields from Rally API for Feature

I am fetching the data using below API :
https://rally1.rallydev.com/slm/webservice/v2.0/PortfolioItem/Feature/?fetch=ObjectID,FormattedID,Name,Parent&pagesize=2000
I don't want to fetch all fields in Parent. All I need Name,FormattedID,ObjectID,Parent.ObjectID,Parent.Name of Feature. A
{
"_rallyAPIMajor": "2",
"_rallyAPIMinor": "0",
"ObjectID": blabla,
"FormattedID": "F3792",
"DirectChildrenCount": 23,
"Name": "Phase 2: Fork Messages (New flow of messages that will feed data to 8 reports for D&P)",
"Parent": {
"_rallyAPIMajor": "2",
"_rallyAPIMinor": "0",
"_ref": "https://rally1.rallydev.com/slm/webservice/v2.0/portfolioitem/portfolio/blabla",
"_refObjectUUID": "8fae",
"_objectVersion": "67",
"_refObjectName": "blabla",
"ObjectID": blabla,
"FormattedID": "P1ABC",
"DirectChildrenCount": 13,
"Name": "blabla",
"_type": "PortfolioItem/Portfolio"
},
"_type": "PortfolioItem/Feature"
}
This is just the way the Web Services API works. Any fields included in the fetch will be returned on any object that has them. This is very useful for being able to hydrate fields on associated objects- Parent, Iteration, etc.

HERE Places API: not all items have PVID

I'm using HERE Places API.
Firstly I'm doing a search.
For Example this query :
https://places.cit.api.here.com/places/v1/discover/search?q=Test&at=35.6111,-97.5467&r=500&size=1&app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg&show_refs=pvid&pretty
According to this documentation (Link) If I add show_refs=pvid to query string, in result I will get external id which I can use to query lookup endpoint.
But in result I get next response :
{
"results": {
"next": "https://places.cit.api.here.com/places/v1/discover/search;context=Zmxvdy1pZD1hY2ExNzk3NC0zYzg3LTU5NzQtYmZkMC04YjAzMDZlYWIzMWJfMTUwNjA3NjMzMTYyMl83NDY3XzM4NTAmb2Zmc2V0PTEmc2l6ZT0x?at=35.6111%2C-97.5467&q=Test&app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg",
"items": [
{
"position": [
35.60369,
-97.51761
],
"distance": 2756,
"title": "Southwest Test & Balance",
"averageRating": 0,
"category": {
"id": "business-services",
"title": "Business & Services",
"href": "https://places.cit.api.here.com/places/v1/categories/places/business-services?app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg",
"type": "urn:nlp-types:category",
"system": "places"
},
"icon": "https://download.vcdn.cit.data.here.com/p/d/places2_stg/icons/categories/02.icon",
"vicinity": "200 NW 132nd St<br/>Oklahoma City, OK 73114",
"having": [],
"type": "urn:nlp-types:place",
"href": "https://places.cit.api.here.com/places/v1/places/8403fv6k-d1b2fde0616e0326e321a54b88cd9f53;context=Zmxvdy1pZD1hY2ExNzk3NC0zYzg3LTU5NzQtYmZkMC04YjAzMDZlYWIzMWJfMTUwNjA3NjMzMTYyMl83NDY3XzM4NTAmcmFuaz0w?app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg",
"id": "8403fv6k-d1b2fde0616e0326e321a54b88cd9f53",
"authoritative": true
}
]
},
"search": {
"context": {
"location": {
"position": [
35.6111,
-97.5467
],
"address": {
"text": "Oklahoma City, OK 73134<br/>USA",
"postalCode": "73134",
"city": "Oklahoma City",
"county": "Oklahoma",
"stateCode": "OK",
"country": "United States",
"countryCode": "USA"
}
},
"type": "urn:nlp-types:place",
"href": "https://places.cit.api.here.com/places/v1/places/loc-dmVyc2lvbj0xO3RpdGxlPU9rbGFob21hK0NpdHk7bGF0PTM1LjYxMTE7bG9uPS05Ny41NDY3O2NpdHk9T2tsYWhvbWErQ2l0eTtwb3N0YWxDb2RlPTczMTM0O2NvdW50cnk9VVNBO3N0YXRlQ29kZT1PSztjb3VudHk9T2tsYWhvbWE7Y2F0ZWdvcnlJZD1jaXR5LXRvd24tdmlsbGFnZTtzb3VyY2VTeXN0ZW09aW50ZXJuYWw;context=c2VhcmNoQ29udGV4dD0x?app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg"
}
}
}
In response no object references
Is it a bug or not every place has this external id?
I am responding as member of the team around HERE Places API.
Yes, not every place has a pvid. That is why I would suggest using the Sharing Id instead. I realize that the documentation should be improved to clarify that.
The Sharing Ids can be obtained by adding show_refs=sharing to either your search query or a place details request. It can be found in the field references. Once you have the sharing id you can you the lookup endpoint as you intended.
Take a look at:
https://places.cit.api.here.com/places/v1/places/8403fv6k-d1b2fde0616e0326e321a54b88cd9f53;context=Zmxvdy1pZD00YWU2ZWZjNi01ZjgzLTUwYTQtOTI4OS0xZjliMGMwNWY3NjBfMTUwNzA0NDE0OTc3NV84MTI5XzU1NDcmcmFuaz0w?app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg&show_refs=pvid
and
https://places.cit.api.here.com/places/v1/places/8409q8yy-6af3c3e50bcb4f859686797b2be5773d;context=Zmxvdy1pZD00YWU2ZWZjNi01ZjgzLTUwYTQtOTI4OS0xZjliMGMwNWY3NjBfMTUwNzA0NDE0OTc3NV84MTI5XzU1NDcmcmFuaz0w?app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg&show_refs=pvid
On those two examples, the only difference is the placeId.
In the docs, there's not a single reference saying that the external identifier is required or existant for every place.
Since it represents an external identifier, I believe we could assume that it's not required.
And it's what we just saw with your place (8403fv6k-d1b2fde0616e0326e321a54b88cd9f53): this one don't have any external identifier.
Based on your comments, what you need is the information about a place.
So, after you run your first query, you should get something like:
{
title: "Southwest Test & Balance",
position: [],
id: "8403fv6k-d1b2fde0616e0326e321a54b88cd9f53",
href: "https://[...]"
}
With this ID, you could access it:
places.cit.api.here.com/places/v1/places/8403fv6k-d1b2fde0616e0326e321a54b88cd9f53;context=Zmxvdy1pZD0zYTFlZjg5ZS02ZTY5LTUxYmEtYWFkYS1kY2UwZWMyNDdkMDBfMTUwNzEzNjUxNjI5N182NjExXzc2OTgmcmFuaz0w?app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg
Or directly using the href information.
This response already is giving you the ID and URL to access all the info of a single place.
You don't need any other external ID or reference.

Deserializing JSON in Visual basic

I want to deserialize this string, it is from a rest api, but i dont know how to do it.
i know i have to create a class with the struture of the string, and i have to run the command with deserialize.
Can anyone help me?
Thanks
"
{
"success": true,
"data": {
"categories": {
"17": [
{
"category_id": "17",
"name": "Software",
"description": "",
"sort_order": "4",
"meta_title": "",
"meta_description": "",
"meta_keyword": "",
"language_id": "1",
"image": "http://newapi3.opencart-api.com/image/cache/catalog/categories/12316636179756542373092288841575795860377n-100x100.jpg",
"categories": null
},
{
"category_id": "17",
"name": "Software",
"description": "",
"sort_order": "4",
"meta_title": "",
"meta_description": "",
"meta_keyword": "",
"language_id": "2",
"image": "http://newapi3.opencart-api.com/image/cache/catalog/categories/12316636179756542373092288841575795860377n-100x100.jpg",
"categories": null
}
],
"18": [
{
"category_id": "18",
"name": "Laptops & Notebooks",
"description": "<p>\r\n\tShop Laptop feature only the best laptop deals on the market. By comparing laptop deals from the likes of PC World, Comet, Dixons, The Link and Carphone Warehouse, Shop Laptop has the most comprehensive selection of laptops on the internet. At Shop Laptop, we pride ourselves on offering customers the very best laptop deals. From refurbished laptops to netbooks, Shop Laptop ensures that every laptop - in every colour, style, size and technical spec - is featured on the site at the lowest possible price.</p>\r\n",
"sort_order": "2",
"meta_title": "",
"meta_description": "",
"meta_keyword": "",
"language_id": "1",
"image": "http://newapi3.opencart-api.com/image/cache/catalog/demo/hp_2-100x100.jpg",
"categories": null
},
{
"category_id": "18",
"name": "Laptops & Notebooks",
"description": "<p>\r\n\tShop Laptop feature only the best laptop deals on the market. By comparing laptop deals from the likes of PC World, Comet, Dixons, The Link and Carphone Warehouse, Shop Laptop has the most comprehensive selection of laptops on the internet. At Shop Laptop, we pride ourselves on offering customers the very best laptop deals. From refurbished laptops to netbooks, Shop Laptop ensures that every laptop - in every colour, style, size and technical spec - is featured on the site at the lowest possible price.</p>\r\n",
"sort_order": "2",
"meta_title": "",
"meta_description": "",
"meta_keyword": "",
"language_id": "2",
"image": "http://newapi3.opencart-api.com/image/cache/catalog/demo/hp_2-100x100.jpg",
"categories": null
}
]
}
}
}"
Use this service to generate classes from JSON strings. It will save you a lot of time (and headache).
After that, you might consider using a third-party library for deserializing the JSON string. You have quite a few options but the most popular and the best according to me, is JSON.NET.
After you have installed it, you can go forward and access whatever data you want after deserializing the JSON.
Example:
Dim data = JsonConvert.DeserializeObject(Of YourDataClass)("<YourJSONString>");
If data.Success Then
Console.WriteLine(data.Data.Categories(0).Name);
End If