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?
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")
0
taz8020Author Commented:
Hi thanks its a .net win form so using Imports Newtonsoft.Json how would I do it with this
0
taz8020Author Commented:
if I import java and use your code I get
The given key was not present in the dictionary.
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

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
0
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-
0

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
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.