Link to home
Start Free TrialLog in
Avatar of taz8020
taz8020Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Vb.net get data from json file

HI I have this json file returned
{  "data": {   "translations": [    {     "translatedText": "Hola"    }   ]  } }

how do I get the translatedText out

Please give a good example or function as quite new to code.
SOLUTION
Avatar of Prakash Samariya
Prakash Samariya
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of taz8020

ASKER

Hi thanks its a .net win form so using Imports Newtonsoft.Json how would I do it with this
Avatar of taz8020

ASKER

if I import java and use your code I get
The given key was not present in the dictionary.
Avatar of taz8020

ASKER

Ok this works but is there a better way to write it?

        Dim testObj = js.Deserialize(jsonData, New Object().GetType())

        Dim TranslatedText

            TranslatedText = testObj("data")
            TranslatedText = TranslatedText("translations")
            TranslatedText = TranslatedText(0)
            TranslatedText = TranslatedText("translatedText")
          TranslatedText = TranslatedText.ToString
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of taz8020

ASKER

Great Thanks