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.
LVL 3
taz8020Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Prakash SamariyaIT ProfessionalCommented:
Dim jObj As Object = New JavaScriptSerializer().Deserialize(Of Object)(JSONString)

'It should get "Hola", use
Dim sTranslatedText = jObj("translations")(0).translatedText  
'OR
Dim sTranslatedText = jObj("translations")(0).("translatedText")
taz8020Author Commented:
Hi thanks its a .net win form so using Imports Newtonsoft.Json how would I do it with this
taz8020Author Commented:
if I import java and use your code I get
The given key was not present in the dictionary.
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

taz8020Author Commented:
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
it_saigeDeveloperCommented:
Perhaps something like:
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq

Module Module1
	Const json = "{""data"":{""translations"":[{""translatedText"":""Hola""}]}}"
	Sub Main()
		Dim [object] = JsonConvert.DeserializeObject(Of JObject)(json)
		For Each root In [object]("data")
			For Each translation In root
				For Each pair In translation
					Console.WriteLine("Translated Text = {0}", pair("translatedText"))
				Next
			Next
		Next
		Console.ReadLine()
	End Sub
End Module

Open in new window

Which produces the following output -Capture.JPG-saige-

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
taz8020Author Commented:
Great Thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.