Comment créer ce JSON code> matry à l'aide de
vb.net code> array
3 Réponses :
Consultez l'extension de la galerie Visual Studio appelée JSON.NET ou accédez à leur page CODEPLEX ( JSON sur CodePlex ) p>
Comme vous utilisez .NET 2.0, vous devez utiliser le JSON librey par James, avec télécharger sur CodePlex (version pour .NET 2.0).
Un exemple d'utilisation de JSON.NET P>
Ajoutez une référence à Exemple: p> {
"Name": "Captopril",
"Expiry": "\/Date(1230375600000+1300)\/",
"Price": 3.99,
"Sizes": [
"Small",
"Medium",
"Large"
]
}
Cela ne fonctionne pas. Il est indiqué que les produits () et JavaScriptConvertConvert ne sont pas définis.
Oui, j'ai utilisé la console Nuget pour installer les dépendances nécessaires
'creating sample student ojects Dim obj1 As New Student() With {.value = "Mick Jagger", .name = 21} Dim obj2 As New Student() With {.value = "Johnny Storm", .name = 43} Dim obj3 As New Student() With {.value = "Richard Hatch", .name = 46} Dim obj4 As New Student() With {.value = "Kelly Slater", .name = 54} 'adding student objects to list Dim objStudentList As New List(Of Student)() From { obj1,obj2, obj3, obj4} Dim objJSSerializer As New System.Web.Script.Serialization.JavaScriptSerializer() 'Serialization .NET Object to JSON strJSON = objJSSerializer.Serialize(objStudentList) Dim csname2 As String = "ButtonClickScript" Dim cstype As Type = Me.GetType() Dim cstext2 As New StringBuilder() Dim cs As ClientScriptManager = Page.ClientScript cstext2.Append("<script type=""text/javascript""> var data = {items: " + strJSON) cstext2.Append(" }; </") cstext2.Append("script>") cs.RegisterClientScriptBlock(cstype, csname2, cstext2.ToString(), False)
Été posé ici Stackoverflow.com/Questtions/579053/...