jjvalstar
asked on
VB.NET - Extract Pairs out of a string (JSON)
I use VB.Net and want to extract The Keypair values and put them into a class with the same variable (names) and values.
When I do a API call the outcome is shown as below.
How can I extract the KeyPair values? Like "Username": "<text>"?
{
"License":
{
"LicenseKey": "Known",
"LicenseId": "****",
"Username": "++",
"Password": "*",
"ProductCode": "*",
"ProductName": "",
"Quantity": 1,
"PurchaseType": "Renew",
"CreatedDate": "28-07-2015",
"ExpirationDate": "27-07-2017",
"CustomerName": "*",
"CustomerCompany": "",
"CustomerEmail": "a@b.com",
"DiscountCode": 0,
"Status": "Active",
"BundleProductCode": "0",
"BundleProductName": "Advanced",
"BundleQuantity": 0,
"ELAPassword": "",
"CountryId": 60
},
"Result": true,
"Messages": []
}
When I do a API call the outcome is shown as below.
How can I extract the KeyPair values? Like "Username": "<text>"?
{
"License":
{
"LicenseKey": "Known",
"LicenseId": "****",
"Username": "++",
"Password": "*",
"ProductCode": "*",
"ProductName": "",
"Quantity": 1,
"PurchaseType": "Renew",
"CreatedDate": "28-07-2015",
"ExpirationDate": "27-07-2017",
"CustomerName": "*",
"CustomerCompany": "",
"CustomerEmail": "a@b.com",
"DiscountCode": 0,
"Status": "Active",
"BundleProductCode": "0",
"BundleProductName": "Advanced",
"BundleQuantity": 0,
"ELAPassword": "",
"CountryId": 60
},
"Result": true,
"Messages": []
}
Import Newtonsoft.Json and try
Dim list As List(Of String) = Newtonsoft.Json.JsonConvert.DeserializeObject(Of List(Of String))(strJSON)
For Each item As String In list
Console.WriteLine(item)
Next
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This was the solution.
Many thanks.
Many thanks.
you can look for samples at Json.NET to do this
for more info
http://www.newtonsoft.com/json