3
{"result":[[{"code reduced":"019076-3","Stock":200,"Price":900.77,"Price":225.19,"Description":" ASUS AMD RADEON R5 VIDEO CARD 230 1GB DDR3 64BITS R5230-SL-1GD3-L *IMP","Group":"VIDEO PLATE","Brand":"ASUS","Origin":6,"NCM":"8473.30.43","EAN":"0000000000000","Weighing":0,"Width":0,"Height":0,"Depth":0,"Warranty":"12 Months","Aliqipi":0,"Aliqicms":12,"Unit":"PC","Multiplovend":1,"Link":"https://www2.meusite.com.br/localnew/_img/fotos_products/019076-3.jpg","Partnumber":"R5230-SL-1GD3-L"}]]}
I’m Sending the Code I’m Developing..
private void ButtonConvert_Click(object sender, EventArgs e)
{
string fileContents;
WebRequest request = WebRequest.Create(textBox1.Text);
WebResponse response = request.GetResponse();
Stream data = response.GetResponseStream();
string html = String.Empty;
using (StreamReader sr = new StreamReader(data))
{
fileContents = sr.ReadToEnd();
}
richTextBox1.Text = fileContents;
JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
Result paging = jsonSerializer.Deserialize<Result>(fileContents);
textBox2.Text = textBox2.Text + paging.Descricao;
for (int i = 0; i < 50; i++)
{
//richTextBox1.Text = richTextBox1.Text + paging.results[i].id + " ";
//richTextBox1.Text = richTextBox1.Text + paging.results[i].buyer.id + " ";
//richTextBox1.Text = richTextBox1.Text + paging.results[i].buyer.first_name + " ";
}
}
public class Result
{
public string CodigoReduzido { get; set; }
public int Estoque { get; set; }
public double Preco { get; set; }
public double PrecoST { get; set; }
public string Descricao { get; set; }
public string Grupo { get; set; }
public string Marca { get; set; }
public int Origem { get; set; }
public string NCM { get; set; }
public string EAN { get; set; }
public double PesoBruto { get; set; }
public int Largura { get; set; }
public int Altura { get; set; }
public int Profundidade { get; set; }
public string Garantia { get; set; }
public int AliqIPI { get; set; }
public int AliqICMS { get; set; }
public string Unidade { get; set; }
public int MultiploVenda { get; set; }
public string Link { get; set; }
public string PartNumber { get; set; }
}
public class RootObject
{
public List<Result> result { get; set; }
}
Using json2csharp generate c# classes from json
public class RootObject
{
public List<List<>> result { get; set; }
}
But I couldn’t use it that way.. Now I think I’ve got a better explanation
I appreciate the help of friends...
Click [Edit] and put your deserialization code there. I think it’s working, the problem is that you have to access these values as an array within another to get the values, that’s all.
– Bacco
Using Visual Studio itself he showed me that I would have to use to access the array in the following way paging[0]. [0] I believe that my problem is in the classes part of the JSON structure.... how to do..
– Gustavo Castilho