已在多列中解析 JSON

Parsed JSON in multiple columns

我正在收集一些 API 信息,我编写了一个程序来读取域并查找 API 信息,在找到信息后,它将整个 JSON 它在 Microsoft SQL 服务器 table.

中制作的文本

这是 JSON 输出之一的样子:

    {
  "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"
  ]
}

图片示例:

所以我现在需要做的是只取出一些数据,如 "Company name"、"category"(包含所有子类别信息)、"employees"、"employeesrange"、"marketcap"、"annnualrevenue" 和 "similardomains"(这个应该作为一个完整的文本列)并在其自己的列中对每个进行排序。如果我能得到任何帮助或指示,我将非常高兴。

使用 JSON_VALUE 函数,您可以从 JSON 列中提取所有数据

  SELECT * , 
     JSON_VALUE(JsonColumn,'$.name') AS CompanyName
     , JSON_VALUE(JsonColumn,'$.category.sector') AS CategorySector
     , JSON_VALUE(JsonColumn, '$.category.industryGroup') AS CategoryIndustryGroup
     -- etc
  FROM YourTable