I have one JSON Request as below :
{
"Products": [
{
"ProductId": 1,
"Barcode": "sample string 2",
"ProductExtId": "sample string 3",
"CategoryName": "sample string 4",
"BrandName": "sample string 5",
"StyleName": "sample string 6",
"ProductName": "sample string 7",
"Properies": [
{
"PropertyKey": "sample string 1",
"PropertyValue": "sample string 2"
},
{
"PropertyKey": "sample string 1",
"PropertyValue": "sample string 2"
}
]
}
]
}
As per above JSON Request my Class AS BELOW :
public class Propery
{
public string PropertyKey { get; set; }
public string PropertyValue { get; set; }
}
public class Product
{
public int ProductId { get; set; }
public string Barcode { get; set; }
public string ProductExtId { get; set; }
public string CategoryName { get; set; }
public string BrandName { get; set; }
public string StyleName { get; set; }
public string ProductName { get; set; }
public List<Propery> Properies { get; set; }
}
public class RootObject
{
public List<Product> Products { get; set; }
//public Product Products { get; set; }
}
My DataController :
[HttpGet]
[ResponseType(typeof(List<productGetData_Result>))]
public async Task<IHttpActionResult> GetProductData()
{
List<Product> prodata = new List<Product>();
var list = db.productGetData().ToList();
foreach (var listdata in list)
{
Product pdata = new Product();
pdata.Barcode = listdata.StockNo;
pdata.ProductExtId = "";
pdata.CategoryName = listdata.Class2Descr;
pdata.BrandName = listdata.Class1Descr;
pdata.StyleName = listdata.SubClass1Cd;
pdata.ProductName = listdata.AnalCode2;
pdata.ProductSubTitle = listdata.AnalCode2;
pdata.ProductImage = listdata.ImageID;
pdata.Color = listdata.SubClass2Cd;
pdata.ColorImage = "";
pdata.FabricName = "";
pdata.SeasonName = listdata.AnalCode3;
pdata.GroupName = listdata.Class2Descr;
pdata.SearchKeywords = listdata.ItemDesc;
pdata.MRP = Convert.ToInt16(listdata.Retail_Price);
pdata.BuyingPrice = Convert.ToInt16(listdata.CurrentCost);
pdata.StockQty = Convert.ToInt16(listdata.StockQty);
pdata.AllowedQty = Convert.ToInt16(listdata.StockQty);
pdata.ProductFor = "";
pdata.AgeType = "";
pdata.AgeFrom = 1;
pdata.AgeTo = 2;
pdata.Age = "";
pdata.KeyFeatures = "";
pdata.Description = listdata.ItemDesc;
pdata.Condition = "";
pdata.Disclaimer = "";
pdata.IsGiftAvailable = true;
pdata.IsPopular = true;
pdata.IsNewArrival = true;
pdata.IsSponsored = true;
pdata.IsShippingAvailable = true;
pdata.CompanyName = "Siddharth Creation";
pdata.ProductAgeDate = Convert.ToDateTime(listdata.Dateinsert);
pdata.IsActive = true;
pdata.IntegrationFor = "Siddharth Creation";
prodata.Add(pdata);
}
using (HttpClient client = new HttpClient())
{
//HttpRequestMessage requestmsg = new HttpRequestMessage(HttpMethod.Get, "http://retailerintegration.zoomi.in");
//requestmsg.Headers.Add("token", "");
string stringData = JsonConvert.SerializeObject(prodata);
client.BaseAddress = new Uri("");
MediaTypeWithQualityHeaderValue contentType =new MediaTypeWithQualityHeaderValue("application/json");
client.DefaultRequestHeaders.Accept.Add(contentType);
var contentData = new StringContent(stringData, System.Text.Encoding.UTF8, "application/json");
HttpResponseMessage response = client.PostAsync("/api/Product/ProductSave", contentData).Result;
var Message = response.Content.ReadAsStringAsync().Result;
}
return Ok(prodata);
}
AS per above class and DataController, i am returning below JSON Response :
[
{
"ProductId": 0,
"Barcode": "170604658",
"ProductExtId": "",
"CategoryName": "MENS SHIRTS",
"BrandName": "KRISS",
"StyleName": "PRN",
"ProductName": "FORMAL WEAR",
"Properies": null
},
{
"ProductId": 0,
"Barcode": "170604657",
"ProductExtId": "",
"CategoryName": "MENS SHIRTS",
"BrandName": "KRISS",
"StyleName": "PRN",
"ProductName": "FORMAL WEAR",
"Properies": null
}
]
currently i am returning product class & its items as per above.
So, now how to pass root object in datacontroller to get the JSON Response as per JSON Request.
List<Product> prodata = new List<Product>();
RootObject _rootObject = new RootObject();
var list = db.productGetData().ToList();
foreach (var listdata in list)
{
var _listOfProperties = new List<Property>();
//if product list contains data of properties
foreach(var _prop in listdata.Properies)
{
var property = new Property();
property.PropertyKey = _prop.PropertyKey;
property.PropertyValue = _prop.PropertyValue;
_listOfProperties.Add(property);
}
Product pdata = new Product();
pdata.Properties = _listOfProperties;
prodata.Add(pdata);
}
_rootObject.Products = prodata;
and now serialize it
string stringData = JsonConvert.SerializeObject(_rootObject);
Related
Could someone helpe me?
How can I code 'Shippings' class as an Array to get the json example below?
{
"seller_id": "123",
"amount": 100,
"order": {
"order_id": "1111",
"sales_tax": 0,
"product_type": "service"
},
"shippings": [{
"first_name": "John",
"phone_number": "5551999887766",
"shipping_amount": 3000,
"address": {
"street": "Street 35 Conts",
"number": "1000",
"complement": "ap1",
"postal_code": "90230060"
}
}],
"credit": {
"delayed": false,
"authenticated": false
}
}
I am doing this below, using asp.net mvc, but don't know how to get Shippings as Array [].
Can someone give me some exemplo or anything else... I'll appreciate.
var request = new GetNetRoot() {
SellerId = seller_id,
Amount = orderItens.Amount
Order = new GetNetPagOrder() {
OrderId = order.id.ToString(),
SalesTax = orderItens.Tax,
ProductType = orderItens.ProdType
},
Shippings = new GetNetPagShippings() {
FirstName = "",
PhoneNumber = usr.PhoneNumber,
ShippingAmount = orderItens.AmountShip,
Address = new GetNetPagAddress() {
Street = catEnd.IdEnderecoLogradouroNavigation.IdRuaNavigation.Nome,
Number = catEnd.NumEndereco,
Complement = catEnd.Complemento,
PostalCode = catEnd.IdEnderecoLogradouroNavigation.Cep
}
},
Credit = new GetNetPagCredit() {
Delayed = false,
Authenticated = false
}
};
var requestBody = JsonConvert.SerializeObject(request)
You should initialize Shippings like an array:
Shippings = new[] {
new GetNetPagShippings()
{
FirstName = "",
PhoneNumber = usr.PhoneNumber,
ShippingAmount = orderItens.AmountShip,
Address = new GetNetPagAddress()
{
Street = catEnd.IdEnderecoLogradouroNavigation.IdRuaNavigation.Nome,
Number = catEnd.NumEndereco,
Complement = catEnd.Complemento,
PostalCode = catEnd.IdEnderecoLogradouroNavigation.Cep
}
}
public class GetNetPagamentoRoot
{
...
public GetNetPagShippings[] Shippings { get; set; }
}
You can use array initializer syntax. Simplistic example would be array of int:
int[] myArray = new [] { 1, 2, 3 }
In your code Shippings should be initialized as an array.
var request = new GetNetRoot()
{
SellerId = seller_id,
Amount = orderItens.Amount
Order = new GetNetPagOrder()
{
OrderId = order.id.ToString(),
SalesTax = orderItens.Tax,
ProductType = orderItens.ProdType
},
// Array initializer with 2 elements.
Shippings = new[] {
new GetNetPagShippings()
{
FirstName = "",
PhoneNumber = usr.PhoneNumber,
ShippingAmount = orderItens.AmountShip,
Address = new GetNetPagAddress()
{
Street = catEnd.IdEnderecoLogradouroNavigation.IdRuaNavigation.Nome,
Number = catEnd.NumEndereco,
Complement = catEnd.Complemento,
PostalCode = catEnd.IdEnderecoLogradouroNavigation.Cep
}
},
new GetNetPagShippings()
{
FirstName = "",
PhoneNumber = usr.PhoneNumber,
ShippingAmount = orderItens.AmountShip,
Address = new GetNetPagAddress()
{
Street = catEnd.IdEnderecoLogradouroNavigation.IdRuaNavigation.Nome,
Number = catEnd.NumEndereco,
Complement = catEnd.Complemento,
PostalCode = catEnd.IdEnderecoLogradouroNavigation.Cep
}
}
},
Credit = new GetNetPagCredit()
{
Delayed = false,
Authenticated = false
}
};
var requestBody = JsonConvert.SerializeObject(request);
Your GetNetRoot outer class needs to define the "Shippings" property as a list or array of the GetNetPagShippings class as opposed to a single instance. When you serialize it to JSON, it will be represented as a JSON array of the object.
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
var myClassInstance = new MyOuterClass()
{
OuterProperty = "Outer Property",
MyInnerClassList = new List<MyInnerClass>()
{
new MyInnerClass()
{
InnerProperty = "Inner Property Item 1"
},
new MyInnerClass()
{
InnerProperty = "Inner Property Item 2"
}
}
};
string json = JsonConvert.SerializeObject(myClassInstance);
Console.WriteLine(json);
}
}
public class MyOuterClass
{
public string OuterProperty { get; set; }
public List<MyInnerClass> MyInnerClassList { get; set; }
}
public class MyInnerClass
{
public string InnerProperty { get; set; }
}
}
I have an object defined as follows.
public class ILT
{
public items items;
public options options;
}
public class items
{
public string course_code { get; set; }
public string session_code { get; set; }
public string date_name { get; set; }
public string date { get; set; }
public string time_start { get; set; }
public string time_end { get; set; }
public string location_name { get; set; }
public string location_address { get; set; }
public string location_country { get; set; }
public items() { }
public items(string course_code, string session_code, string date_name,
string date, string time_start, string time_end, string location_name,
string location_address, string location_country)
{
this.course_code = course_code;
this.session_code = session_code;
this.date_name = date_name;
this.date = date;
this.time_start = time_start;
this.time_end = time_end;
this.location_name = location_name;
this.location_address = location_address;
this.location_country = location_country;
}
}
I'm trying to pass the object into a RestfulAPI request body. The "items" attribute is supposed to be an array of objects.
The JSon should be formatted as follows:
{
"items": [
{
"course_id": 6,
"session_code": "my session code",
"session_name": "my session name",
"session_maximum_enrollments": 20,
"session_last_subscription_date": "2018-10-27",
"completion_type": "Evaluation",
"score_base": 100,
"date_name": "my date name",
"date": "2018-10-28",
"timezone": "America/New_York",
"time_start": "08:00:00",
"time_end": "12:00:00",
"location_name": "my location name",
"location_address": "10850 W. Park Place Suite 600, Milwaukee, WI 53225",
"location_country": "UNITED STATES OF AMERICA"
}
],
"options": {
"update_session_info": true
}
}
I'm having difficulty getting the items into an array. I'm trying to initialize the object into the request body as follows:
public bool CreateILT()
{
if (String.IsNullOrEmpty(Token))
Token = request.GetToken();
ILT classroom = new ILT
{
items = new items[0]
(
course_code = "APS_CLASSROOM",
session_code = "APS_CLASSROOM",
date_name = "August 27, 2018",
date = "2018-10-27",
time_start = "08:00:00",
time_end = "17:00:00",
location_name = "Crisis Prevention Institute",
location_address = "10850 W. Park Place Suite 600, Milwaukee, WI 53225",
location_country = "UNITED STATES OF AMERICA"
),
options = new options
{
update_session_info = true
}
};
dynamic response = request.Request_POST("/learn/v1/ilt/session/batch", Token, classroom);
if (response.data.success.ToString() == "True")
success = true;
return success;
}
Am I able to initialize an object array like this? I'm getting errors of various types when tweaking around. The above code errors out on each of the object's member's saying it does not exist in the current context.
Your class variable decleration is wrong. It stores object, not array/list of objects. And I could not see your options class. Do you have it right?
It should be declared as follows:
public class ILT
{
public List<items> items;
public options options;
}
And you should initialize it as follows:
ILT classroom = new ILT
{
items = new List<items> {
new item(
course_code = "APS_CLASSROOM",
session_code = "APS_CLASSROOM",
date_name = "August 27, 2018",
date = "2018-10-27",
time_start = "08:00:00",
time_end = "17:00:00",
location_name = "Crisis Prevention Institute",
location_address = "10850 W. Park Place Suite 600, Milwaukee, WI 53225",
location_country = "UNITED STATES OF AMERICA")
},
options = new options
{
update_session_info = true
}
};
var singleItems = new List<Products>();
singleItems.Add(new Products() { product_id = 1, title = "Bryon Hetrick", price = 50 });
singleItems.Add(new Products() { product_id = 2, title = "Nicole Wilcox", price = 20 });
var serializer = new JavaScriptSerializer();
var serializedResult = serializer.Serialize(serializer);
From above example code i am getting Json output like bellow.
[{"product_id":1,"title":"Bryon Hetrick","price":50},
{"product_id":2,"title":"Nicole Wilcox","price":20}]
But my Json need one more value called- "config" also i need whole data formatted exactly like bellow. How to edit my c# code to achieve that value?
{ "products":[{"product_id":"B071H6TBM5","title":"New Iphone 5S","price":"23.45"},{"product_id":"B071DM968J","title":"Iphone 4 old","price":"23.45"}],"config":{"token":"","Site":"Us","Mode":"ListMyItem"}}
You could make a Config class with the properties you require and then a composite class with Prodcuts and Config, i.e. ProductConfig:
public class Products
{
public string product_id { get; set; }
public string title { get; set; }
public string price { get; set; }
}
public class Config
{
public string token { get; set; }
public string site { get; set; }
public string mode { get; set; }
}
public class ProductConfig
{
public List<Products> Products { get; set; }
public Config Config { get; set; }
}
You can then create/populate the ProductConfig class with the new properties.
public string SerializeProductConfig()
{
ProductConfig pc = new ProductConfig();
pc.Config = new Config { token = "DDTest", site = "US", mode = "Test Mode" };
pc.Products = new List<Products>();
pc.Products.Add(new Products() { product_id = "1", title = "Bryon Hetrick", price = "50" });
pc.Products.Add(new Products() { product_id = "2", title = "Nicole Wilcox", price = "20" });
var serializer = new JavaScriptSerializer();
return serializer.Serialize(pc);
}
and serialize the ProductConfig object using the JavaScript serializer or NewtonSoft which will give you the following JSON
{ // ProductConfig
"Products": [
{
"product_id": "1",
"title": "Bryon Hetrick",
"price": "50"
},
{
"product_id": "2",
"title": "Nicole Wilcox",
"price": "20"
}
],
"config": {
"token": "DDTest",
"site": "US",
"mode": "Test Mode"
}
}
I want to create JSON object with following format:-
{
"result": [
{
"name": "John",
"address": "US",
},
{
"name": "Josh",
"address": "Japan",
}
],
"error": [
{
"message": "error-message"
}
],
"success": [
{
"message": "success-message"
}
]
}
I have tried the following, but it doesn't help me.
dynamic record = new { result = new {name="", address=""},
error = new {message=""},
success = new {message=""} };
Update 1:-
Here is my code:-
List addressList = new List();
// Loop over items within the container and URI.
foreach (var item in items)
{
dynamic record = new { result = new object[] {
new {name = item.name, address = item.address} } };
addressList.Add(record);
}
Result:-
[ {
"result": [
{
"name": "John",
"address": "US"
}
]
},
{
"result": [
{
"name": "Jack",
"address": "CA"
}
]
}
]
Expected json result:-
[{
"result": [{
"name": "John",
"address": "US"
}]
},
{
"result": [{
"name": "Jack",
"address": "CA"
}],
"error": [{
"message": "error-message"
}],
"success": [{
"message": "success-message"
}]
}
]
How do I update my code to get above expected json result?
You...create arrays. You're not doing that. You're creating individual objects.
Something along the lines of:
dynamic record = new {
result = new object[] {
new {name = "John", address = "US"},
new {name = "Josh", address = "Japan"}
},
error = new object[] /*...*/,
success = new object[] /*...*/
};
If you want exactly JSON, then newtonsoft.Json makes it easier:
Json json = new Json();
json.result = new object[] {
new {name = "John", address = "US"},
new {name = "Josh", address = "Japan"}
};
// json.error = ... and so on
string output = JsonConvert.SerializeObject(product);
The output you will have is:
{
"result": [
{
"name": "John",
"address": "US",
},
{
"name": "Josh",
"address": "Japan",
}
],
"error": [
{
...
}
]
}
To deserialize it back, use:
Json deserializedJson = JsonConvert.DeserializeObject<Json>(output);
you are not creating an array
if you want to create JSON arrays from c# you have to use the following POCO
public class Result
{
public string name { get; set; }
public string address { get; set; }
}
public class Error
{
public string message { get; set; }
}
public class Success
{
public string message { get; set; }
}
public class RootObject
{
public List<Result> result { get; set; }
public List<Error> error { get; set; }
public List<Success> success { get; set; }
}
and then use Json.net
var json = JsonConvert.SerializeObject( "your instance of the root Object")
//You need to make this class structure first
public class Response
{
public List<Result> result { get; set; }
public List<Error> error { get; set; }
public List<Success> success { get; set; }
}
public class Result
{
public string name { get; set; }
public string address { get; set; }
}
public class Error
{
public string message { get; set; }
}
public class Success
{
public string message { get; set; }
}
// And then you can use it like this
var response = new Response()
{
result = new List<Result>
{
new Result() {name = "Jhon", address = "US"},
new Result() {name = "Jhon", address = "US"},
},
error = new List<Error>()
{
new Error() {message = "error-message 1"},
new Error() {message = "error-message 2"}
},
success = new List<Success>()
{
new Success(){message = "success-message 1"},
new Success(){message = "success-message 2"},
}
};
The Model Class
public class MegaMenu
{
public int department_id { get; set; }
public string department_name { get; set; }
public List<SectionListData> sectionListData { get; set; }
}
public class SectionListData
{
public int section_id { get; set; }
public string section_name { get; set; }
public List<ItemHeadList> itemHeadList { get; set; }
}
public class ItemHeadList
{
public int item_head_id { get; set; }
public string item_name { get; set; }
}
public class WrapperMegaMenu
{
public List<MegaMenu> megaMenuList { get; set; }
public string error { get; set; }
}
The Services
dept_result is the array of all department,section_result is the array of all section,Item_result is the array of all items
List<MegaMenu> listmenu = new List<MegaMenu>();
foreach (var each_dept in dept_result)
{
MegaMenu megaMenu = new MegaMenu();
megaMenu.department_id = each_dept.shopdepartment_id;
megaMenu.department_name = each_dept.name_en;
var temSectionList = section_result
.Where(item => item.shopdepartment_id == each_dept.shopdepartment_id).ToList().Select(sectionData => new SectionListData
{
section_id = sectionData.shopsection_id,
section_name = sectionData.name_en,
itemHeadList = Item_result.Where(itemHead => itemHead.shopsection_id == sectionData.shopsection_id).ToList().Select(itemHeadData => new ItemHeadList {
item_head_id = itemHeadData.item_head_id,
item_name = itemHeadData.name_en
}).ToList()
}).ToList();
megaMenu.sectionListData = temSectionList;
listmenu.Add(megaMenu);
}
//wrapperDept.departmentList = dept_result.ToList();
wrapper.megaMenuList = listmenu.ToList();
Result
{
"megaMenuList": [
{
"department_id": 71,
"department_name": "Baby's Hygiene",
"sectionListData": [
{
"section_id": 56,
"section_name": "Diapers",
"itemHeadList": []
},
{
"section_id": 57,
"section_name": "Wipes",
"itemHeadList": [
{
"item_head_id": 142,
"item_name": "Telivision"
}
]
}
]
}
]
}
I have project which uses Json data, I try deserialize a Json data like this:
[{"232":{"id":"232","reference":"022222","name":"Poire","content_title":"","content":"","pv_ttc":"230","picture_1":"","picture_2":"","picture_3":"","picture_4":"","picture_5":""}}]
If I correctly understand Json, at the beginning we have an index, then a sub-board with the name the reference the price etc.
Well, how to deserialize this text to object?
Knowing that I have my class as this:
public class productClass
{
public string id {get;set;}
public string reference { get; set; }
public string name { get; set; }
public string content_title{ get; set; }
public string content { get; set; }
public float pv_ttc{get;set;}
public string picture_1{get;set;}
public string picture_2{get;set;}
public string picture_3{get;set;}
public string picture_4{get;set;}
public string picture_5{get;set;}
public List<productClass> urlResult;
public productClass ( )
{
}
public productClass (string _id, string _reference, string _name, string _content_title, string _content, float _pv_ttc, string _picture_1, string _picture_2, string _picture_3, string _picture_4, string _picture_5)
{
id = _id;
reference = _reference;
name = _name;
content_title = _content_title;
content = _content;
pv_ttc = _pv_ttc;
picture_1 = _picture_1;
picture_2 = _picture_2;
picture_3 = _picture_3;
picture_4 = _picture_4;
picture_5 = _picture_5;
urlResult = new List<productClass> ( );
}
public void addUrl ( List<productClass> urlResult )
{
foreach ( productClass _url in urlResult )
{
urlResult.Add ( _url );
}
}
}
Thanks for help.
#sachou have you considered using JSON.Net? It is a really nice framework for .Net and you can easily de-serialize JSON strings into your C# objects. You can have a look in the documentation, but here is a simple example from the website:
Product product = new Product();
product.Name = "Apple";
product.ExpiryDate = new DateTime(2008, 12, 28);
product.Price = 3.99M;
product.Sizes = new string[] { "Small", "Medium", "Large" };
string output = JsonConvert.SerializeObject(product);
//{
// "Name": "Apple",
// "ExpiryDate": "2008-12-28T00:00:00",
// "Price": 3.99,
// "Sizes": [
// "Small",
// "Medium",
// "Large"
// ]
//}
Product deserializedProduct = JsonConvert.DeserializeObject<Product>(output);
I hope this helps.
I'd suggest you use a JSON Framework like
Newtonsoft JSON.NET
You can very easily serialize and deserialize JSON objects like this:
Product product = new Product();
product.Name = "Apple";
product.ExpiryDate = new DateTime(2008, 12, 28);
product.Price = 3.99M;
product.Sizes = new string[] { "Small", "Medium", "Large" };
string output = JsonConvert.SerializeObject(product);
//{
// "Name": "Apple",
// "ExpiryDate": "2008-12-28T00:00:00",
// "Price": 3.99,
// "Sizes": [
// "Small",
// "Medium",
// "Large"
// ]
//}
Product deserializedProduct = JsonConvert.DeserializeObject<Product>(output);
Take a closer look at Serializing/Deserializing JSON with JSON.net
Here is my example. I am using google map api as an example
I create following class corresponding to google maps
public class AddressComponent
{
public string long_name { get; set; }
public string short_name { get; set; }
public List<string> types { get; set; }
}
public class Result
{
public List<AddressComponent> address_components { get; set; }
public List<string> types { get; set; }
}
public class RootObject
{
public List<Result> results { get; set; }
public string status { get; set; }
}
Then I created this method
public string GetZipCodeBasedonCoordinates()
{
string zip = "";
string url2 = #"https://maps.googleapis.com/maps/api/geocode/json?latlng=37.423021, -122.083739&sensor=false";
System.Net.WebClient web = new System.Net.WebClient();
var result = web.DownloadString(url2);
RootObject root = JsonConvert.DeserializeObject<RootObject>(result);
var allresults = root.results;
foreach (var res in allresults)
{
foreach (var add in res.address_components)
{
var type = add.types;
if (type[0] == "postal_code")
{
zip = add.long_name;
}
}
}
return zip;
}
You can go here to see the resulting json that I have parsed
https://maps.googleapis.com/maps/api/geocode/json?latlng=37.423021,%20-122.083739&sensor=false
For more informations, see my deserialize's method :
public IEnumerator loadProducts (int cat)
{
List <int> catNoTri = new List<int> ();
catNoTri.Add (0);
gm.totalPriceItem.Clear();
isLoading = true;
WWW www = new WWW ( urlProduct );
yield return www;
Debug.Log(www.text);
string json = www.text.ToString ( );
IndexPrductClass myJson = JsonReader.Deserialize<IndexPrductClass> ( json );
foreach (productClass item in products)
{
for (int i = 0; i < products.Length; i++)
{
Debug.Log("product.productValue[i] = " + products[i].name);
}
if (firstLoad || gm.catId == 0)
{
Debug.Log ("here1");
nameProduct.Add (item.name);
Debug.Log("item.name = " + item.name);
idProduct.Add (item.id);
prixItem.Add (item.pv_ttc);
Debug.Log("item.pv_ttc = " + item.pv_ttc);
gm.totalPriceItem.Add (0);
gm.qte = new int [gm.totalPriceItem.Count];
descriptifProduct.Add (item.content);
Debug.Log(" item.content = " +item.content);
}
else if (!firstLoad)
{
Debug.Log ("here2");
nameProduct.Add (item.name);
idProduct.Add (item.id);
prixItem.Add (item.pv_ttc);
gm.totalPriceItem.Add (0);
gm.qte = new int [gm.totalPriceItem.Count];
descriptifProduct.Add (item.content);
}
}
gm.canLoad = true;
}