Deserializing JSON in Visual basic - vb.net

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

Related

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

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.

Parsed JSON in multiple columns

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

When I use filterBy my Vue.js application stops working

When I am using filterBy my application stop working, and nothing shows up in the page the VM instance div is missing form the DOM. What might be the reason?
<div v-else v-for="events in profDetails.events | filterBy events.type">
Below is the JSON Format :
{
"usrId": "1",
"events": [{
"sdate": "02/13/2017",
"author": "suthota1#email.com",
"imgsmall": "images/backgroundhead.svg",
"usrId": 1,
"title": "BigFix Detect (Endpoint Detection & Response) Marketing Announce",
"type": "announcements",
"edate": "02/13/2017",
"tags": "",
"bu": ["Security"],
"scope": "CISOs, SOC Analysts",
"contact": "",
"createTS": "June 01, 2017 # 04:53 PM",
"id": 1,
"region": "North America",
"imglarge": "images/backgroundhead.svg",
"kma": "New landing page, demo video, webinar, comprehensive digital campaign, try/buy offer, immersive demos at RSA, analyst quick take report",
"status": "Published",
"desc": "IBM launches new rapid threat detection and remediation platform. The top tactic employed by attackers is to avoid being detected in the first place. This has spawned a flood of endpoint detection and response (EDR) tools that have primarily focused on detection of endpoint threats. Unlike other vendors, BigFix sees, understands and acts on all threats on the endpoint through a single platform, detecting malicious behavior and delivering targeted remediation on impacted endpoints enterprise wide in minutes."
}, {
"sdate": "07/26/2017",
"author": "suthota1#email.com",
"imgsmall": "images/backgroundhead.svg",
"usrId": 1,
"title": "IBM X-Force Red Portal 2.0",
"type": "announcements",
"edate": "07/26/2017",
"tags": "",
"bu": ["Security"],
"scope": "Technical security testing",
"contact": "",
"createTS": "June 01, 2017 # 04:53 PM",
"id": 2,
"region": "North America",
"imglarge": "images/backgroundhead.svg",
"kma": "Announce as Tier 1 story at Blackhat for Security",
"status": "Published",
"desc": "TECHIBM X-Force Red, is a new global force of the industry's."
}],
"status": "SUCCESS"
}

Sencha touch 2, printing nested JSON array using xtemplate

I am developing a simple movie listing app.
I am using rotten tomatoes api. following is the json :
movies": [{
"id": "771310572",
"title": "Cloud Atlas",
"year": 2012,
"mpaa_rating": "R",
"runtime": 163,
"release_dates": {
"theater": "2012-10-26"
},
"ratings": {
"critics_rating": "Fresh",
"critics_score": 80,
"audience_score": 98
},
"synopsis": "Cloud Atlas explores how the actions and consequences of individual lives impact one another throughout the past, the present and the future. Action, mystery and romance weave dramatically through the story as one soul is shaped from a killer into a hero and a single act of kindness ripples across centuries to inspire a revolution in the distant future. Each member of the ensemble appears in multiple roles as the stories move through time. -- (C) Warner Bros.",
"posters": {
"thumbnail": "http://content6.flixster.com/movie/11/16/71/11167192_mob.jpg",
"profile": "http://content6.flixster.com/movie/11/16/71/11167192_pro.jpg",
"detailed": "http://content6.flixster.com/movie/11/16/71/11167192_det.jpg",
"original": "http://content6.flixster.com/movie/11/16/71/11167192_ori.jpg"
},
"abridged_cast": [{
"name": "Tom Hanks",
"id": "162655641",
"characters": ["Dermot 'Duster' Hoggins", "Dr. Henry Goose", "Isaac Sachs", "Valleysman Zachry"]
}, {
"name": "Halle Berry",
"id": "162652386",
"characters": ["Jocasta Ayrs", "Luisa Rey", "Meronym"]
}, {
"name": "Jim Broadbent",
"id": "162653369",
"characters": ["Vyvyan Ayrs"]
}, {
"name": "Hugo Weaving",
"id": "162709905",
"characters": ["Bill Smoke", "Nurse Noakes", "Old Georgie"]
}, {
"name": "Jim Sturgess",
"id": "563717190",
"characters": ["Adam Ewing", "Hae-Joo Im"]
}]
I am able to get the first list view showing the list of movies and ontap on movie list item, I am able to load the next view to show the movie details.
I am stuck in displaying abridged_cast in the xtemplate. if I use {abridged_cast} the page displays object, Object.
I am unable to find any functions which will extract the values from this array and display.
How to display the array content in the template?
Thanks.