0

I am using Newtonsoft within .net to parse json content and wish I had actually studied this better. I create an obj to parse the string text by listing all the children into a list of JTOkens and then grab the individual values from each JProperty. But now I need to capture a list of values and not sure how to that.

 Dim jobj As JObject = JObject.Parse(msg.Body.ToString())
 Dim results As List(Of JToken) = jobj.Children().ToList
 For Each item As JProperty In results
            item.CreateReader()
            If item.Name = "id" Then
                statid = item.Value
            End If
 etc...

But now I find the following item within the object and need all the "values" and "Tags"

{"results":
 {
 {
   "language": {
   "value": "ja"
},
"matching_results": [
{
  "value": "iPhone5",
  "tag": "JOE"
},
{
  "value": "iPhone5",
  "tag": "BOB"
}
],}

2 Answers 2

1

I have same problem while handling JSON and I find this solution:-

function jsonParse(data)
{
  if(typeof data=='object')
  {
    for(var obj in data)
    {
      if(obj=='value')
      {
        console.log('value---',data[obj])
      }
      else if(obj=='tag')
      {
        console.log('tag---',data[obj])
      }
      jsonParse(data[obj])
    }
  }      
}

Please remove all console with your variable, I hope this will help you.

Sign up to request clarification or add additional context in comments.

Comments

0

It was just a matter of breaking the object into token and reading the values into a list.

 Dim tags As List(Of JToken) = 
 item.Last.SelectToken("matching_results").Children()("tag").ToList

1 Comment

Please add some explanatory text to make this a useful answer - thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.