Convert JArray to array of doubles

Oct 17, 2010 at 4:14 PM

Hi,

I have a JArray that I want to convert to an array of doubles (see the JSON and code below).   Right now I am accessing each item in the JArray in a For Each statement.  This is terribly ineffcient.  Does anyone know of a better way to do this?

{
  "v": {
          "value": [
              1,
              2,
              3,
              4,
              5,
              6,
              7,
              8,
              9,
              10
           ]
        }
 }

 

        Dim jvalues As JArray
        Dim jvalue As Object
        Dim values As List(Of Double)

        values = New List(Of Double)

        jvalues = jobj("value")
        If (Not jvalues Is Nothing) Then
            For Each jvalue In jvalues
                values.Add(jvalue.Value)
            Next
        End If

        values.ToArray