1

I need to parse a simple Json, but the answer is not allways the same, in the past i have created a class with tools like http://jsonutils.com/ but in this case one of the parameter changes.. this is an example of the JSON:

{"success": 1,
 "message": "Registros recuperados",
 "data": {
    "rows": [
            {
             "id_jugador": "454",
             "nombre": "ALEXANDER",
             "apellido": "CABRERA",
             "id_equipo": "5",
             "equipo": "TIBURONES",
             "hr": "21"
            }
            ] 
         },
  "total": 1
}

The problem is that the last item (hr in this case, changes some time will be hits, or have some other name), until now i have been using something like this..

    jsonObjectIntance = JsonConvert.DeserializeObject(Of jsonObjectClass)(jsonString)

how do I parse it if the last parameter changes?? the hr itself con be other baseball statistics like hits, or doubles, triples, strikeouts, etc... , thanks!

leonedo
  • 19
  • 1
  • 6
  • The question is a bit unclear. The "hr" parameter changes to what? Something other than "21"? – allen1 Sep 05 '14 at 21:28
  • Does [this](http://stackoverflow.com/questions/3142495/deserialize-json-into-c-sharp-dynamic-object) help? – OneFineDay Sep 05 '14 at 23:11
  • @Dan the hr is the part that changes... the hr itself.. some times its hr but can also be hits or h2, h3, and several other baseball statistics.. – leonedo Sep 06 '14 at 19:24
  • @OneFineDay thanks, i will try some of the answers, i think something like that is what i need.. i don't know C# but there are some simple and interesting answers.. – leonedo Sep 06 '14 at 19:29

1 Answers1

0

thanks to @OneFineDay for the link, the difficult part for me was the access to data inside the object.

 Dim item As Object = JsonConvert.DeserializeObject(Of Object)(json)

 Dim success as string  = item("success")
 Dim data As Object = item("data")
 Dim rows As JArray = data("rows")
 DataGridView1.DataSource = rows
leonedo
  • 19
  • 1
  • 6