I'm trying to create a way to convert an entire json file into my custom datatype which is called a product
{
"unique_image_url_prefixes":[
],
"products_and_categories":{
"Tops/Sweaters":[
{
"name":"Knit Stripe S/S Raglan Top",
"id":302418,
"image_url":"//d17ol771963kd3.cloudfront.net/129807/ca/_9UoFPZi8Zs.jpg",
"image_url_hi":"//d17ol771963kd3.cloudfront.net/129807/rc/_9UoFPZi8Zs.jpg",
"price":9900,
"sale_price":0,
"new_item":true,
"position":10,
"category_name":"Tops/Sweaters",
"price_euro":11600,
"sale_price_euro":0
}
],
"Shirts":[
{
"name":"Supreme®/Comme des Garçons SHIRT® Eyes Rayon Shirt",
"id":302426,
"image_url":"//d17ol771963kd3.cloudfront.net/132067/ca/9O934PRlIcw.jpg",
"image_url_hi":"//d17ol771963kd3.cloudfront.net/132067/rc/9O934PRlIcw.jpg",
"price":25800,
"sale_price":0,
"new_item":true,
"position":3,
"category_name":"Shirts",
"price_euro":29800,
"sale_price_euro":0
}
]
}
}
This only shows a few parts of the file the entire source is here, PasteBin
So what I'm trying to do is I convert each part of this (It's a product/item)
{
"name":"Knit Stripe S/S Raglan Top",
"id":302418,
"image_url":"//d17ol771963kd3.cloudfront.net/129807/ca/_9UoFPZi8Zs.jpg",
"image_url_hi":"//d17ol771963kd3.cloudfront.net/129807/rc/_9UoFPZi8Zs.jpg",
"price":9900,
"sale_price":0,
"new_item":true,
"position":10,
"category_name":"Tops/Sweaters",
"price_euro":11600,
"sale_price_euro":0
}
To my custom datatype called Product
public Product(string id_p, string name_p, string image_url_p, string category_name_p)
{
id = id_p;
name = name_p;
image_url = image_url_p;
category_name = category_name_p;
}
Then after that I'm trying to compare each of these values to a value assigned by the user of my program
List<Product> products = JsonConvert.DeserializeObject<List<Product>>(JsonString);
if (products == null) return null;
foreach (var product in products)
{
// ownerform.Log(product.name, 0);
if (product.category_name == T.item.Category && product.name.ToLower().Contains(T.item.Keyword.ToLower()))
{
ownerform.Log(string.Format("Resolved Keyword! Item : {0}", product.name), T.TID);
return new GetUrlResponse(true, product);
}
}
What I'm doing right now does not work and I really can't find what does.