Soy nuevo con el JSON
y estoy tratando de crear un String
de la siguiente forma:
{
"preference_id":"Preference_ID" ,
"items": [
{
"id": "123",
"category_id": null,
"currency_id": "ARS",
"description": "asd",
"picture_url": null,
"title": "1",
"quantity": 1,
"unit_price": 1
}
],
"marketplace": "1234323",
"external_reference": "default",
"additional_info": "additional information"
}
Pero cuando yo lo genero, no encuentro la forma que me aparezcan los corchetes []
después del items
. El código que yo genero queda de la siguiente manera:
{
"preference_id":"preference_id",
"items":
{
"id":1,
"category_id":"gase001",
"currency_id":"[FAKER][CURRENCY][ACRONYM]",
"description":"Gaseosa 350ml",
"picture_url":"picture",
"title":"Gaseosa 350",
"quantity":1,
"unit_price":1
},
"marketplace":"None",
"external_reference":"Defaults",
"additional_info":"algo"
}
Para realizar este código utilizo las siguiente clases:
Public Class Preference
<JsonProperty("preference_id")>
Public preference_id As String
<JsonProperty("items")>
Public items As Items
<JsonProperty("marketplace")>
Public marketplace As String
<JsonProperty("external_reference")>
Public external_reference As String
<JsonProperty("additional_info")>
Public additional_info As String
end Class
Public Class Items
<JsonProperty("id")>
Public id As Integer
<JsonProperty("category_id")>
Public category_id As Object
<JsonProperty("currency_id")>
Public currency_id As String
<JsonProperty("description")>
Public description As String
<JsonProperty("picture_url")>
Public picture_url As String
<JsonProperty("title")>
Public title As String
<JsonProperty("quantity")>
Public quantity As Integer
<JsonProperty("unit_price")>
Public unit_price As Integer
end class
Y este es parte del código que utilizo para la generación del JSON
el cual me lo genera sin los corchetes como lo mencione anteriormente.
Dim orden As Preference = New Preference With {
.preference_id = asd,
.additional_info = "asd",
.external_reference = "Defaults",
.marketplace = "None",
.items = New Items With {
.id = "0001",
.category_id = "gase001",
.currency_id = "[FAKER][CURRENCY][ACRONYM]",
.description = "Gaseosa 350ml",
.picture_url = "picture",
.title = "Gaseosa 350",
.quantity = 1,
.unit_price = 1
}
}
Dim result = JsonConvert.SerializeObject(orden)