To serialize a Json in Vb.Net Datacontractattribute.
First you would have to create an object to receive this JSON, realize that your example pussui objects inside the Json own, example:
"atividades_secundarias": [
{
"text": "Reprodução de vídeo em qualquer suporte",
"code": "18.30-0-02"
},
In this case it is an object called atividades_secundarias
with two attributes text
and code
. What alias is a Array
To Serialize you can do :
1.You will create a method that will receive this JSON and do the deserialization
' VB.NET
Private Function DeserializarDataContractJsonSerializer() As List(Of SeuObjeto)
Using Stream = New System.IO.FileStream(JsonQueVocêPassa, System.IO.FileMode.Open)
Dim Serializer = New System.Runtime.Serialization.Json.DataContractJsonSerializer(GetType(List(Of Pedido)))
Return DirectCast(Serializer.ReadObject(Stream), List(Of SeuObjeto))
End Using
End Function
JsonQueVocêPassa =
https://www.receitaws.com.br/v1/cnpj/27865757000102
SeuObjeto =
Object you create with the Json structure you are trying to serialize.
In this example you are reading a Json from a file using and mounting the object.
If you wanted some examples have on the website of Microsoft and also this
Tutorial
That page would be a JSON right ? You would have to look how to serialize a Json with
vb.net
– William Cézar
how could I do that?
– Matheus Menegatte
Were any of the answers helpful?
– William Cézar