7
votes

Comment créer une matrice JSON en utilisant vb.net

Comment créer ce JSON matry à l'aide de vb.net array xxx


1 commentaires

Été posé ici Stackoverflow.com/Questtions/579053/...


3 Réponses :


1
votes

Consultez l'extension de la galerie Visual Studio appelée JSON.NET ou accédez à leur page CODEPLEX ( JSON sur CodePlex )


0 commentaires

8
votes

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 à newtonsoft.json forte>, et une importe NEWTONSOFT.JSON forte> dans votre classe. P>

Exemple: p>

{
  "Name": "Captopril",
  "Expiry": "\/Date(1230375600000+1300)\/",
  "Price": 3.99,
  "Sizes": [
    "Small",
    "Medium",
    "Large"
  ]
}


2 commentaires

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



6
votes
'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)

0 commentaires