pamela rizk
asked on
asp Json
dear all
please i need help i am stuck for three days
Dim sJSON1 As String = "{'ConditionParameter' : {'DocType':'6', 'Reference_Num':'573942', 'StkMethod':'LOAD_H' }}"
no problem when using the below command :
dim ArrayList = new ArrayList
For Each Dict As KeyValuePair(Of String, Object) In mydictionnary 'ex :ID1, arraylist
Array_List.Add(TryCast(Dic t.Value, ArrayList))
Next
Array_List(0) is not nothing
but
Dim sJSON1 As String = "{'ConditionParameter' : [{'DocType':'6', 'Reference_Num':'573942', 'StkMethod':'LOAD_H' }]}"
no problem when using the below command :
dim ArrayList = new ArrayList
For Each Dict As KeyValuePair(Of String, Object) In mydictionnary 'ex :ID1, arraylist
Array_List.Add(TryCast(Dic t.Value, ArrayList))
Next
Array_List is nothing
so in brief if no "[" in the json i have an error please help asap.
please i need help i am stuck for three days
Dim sJSON1 As String = "{'ConditionParameter' : {'DocType':'6', 'Reference_Num':'573942', 'StkMethod':'LOAD_H' }}"
no problem when using the below command :
dim ArrayList = new ArrayList
For Each Dict As KeyValuePair(Of String, Object) In mydictionnary 'ex :ID1, arraylist
Array_List.Add(TryCast(Dic
Next
Array_List(0) is not nothing
but
Dim sJSON1 As String = "{'ConditionParameter' : [{'DocType':'6', 'Reference_Num':'573942', 'StkMethod':'LOAD_H' }]}"
no problem when using the below command :
dim ArrayList = new ArrayList
For Each Dict As KeyValuePair(Of String, Object) In mydictionnary 'ex :ID1, arraylist
Array_List.Add(TryCast(Dic
Next
Array_List is nothing
so in brief if no "[" in the json i have an error please help asap.
ASKER
what i am trying to say is that i have ajson
Dim sJSON1 As String = "{'ConditionParameter' : [{'DocType':'6', 'Reference_Num':'573942', 'StkMethod':'LOAD_H' }]}"
i need to deserialize it intoa dataset how to do i??
Dim sJSON1 As String = "{'ConditionParameter' : [{'DocType':'6', 'Reference_Num':'573942', 'StkMethod':'LOAD_H' }]}"
i need to deserialize it intoa dataset how to do i??
ASKER
sorry to say but still now working please helpp
ASKER
please help since i am stuck
E.g. using Newtonsoft.Json (use nuget to install that pakage):
Imports Newtonsoft.Json
Module Module1
Sub Main()
Dim jsonString As String = "{'ConditionParameter' : [{'DocType':'6', 'Reference_Num':'573942', 'StkMethod':'LOAD_H' }]}"
Dim parameters As DataSet = JsonConvert.DeserializeObject(Of DataSet)(jsonString)
Dim parametersTable As DataTable = parameters.Tables("ConditionParameter")
Console.WriteLine(parametersTable.Rows.Count)
For Each row As DataRow In ParametersTable.Rows
Console.WriteLine(row("DocType") + " - " + row("Reference_Num") + " - " + row("StkMethod"))
Next row
Console.WriteLine("Done.")
Console.ReadLine()
End Sub
End Module
ASKER
is there any alternative for newtonsoft?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You've defined sJSON1, but you don't use it at all. What does mydictionnary contain? Who does it declaration look like? Why transforming it into an ArrayList?