Когда я пытаюсь преобразовать массив URL-адресов JSON в список строковых ошибок, возникает ошибка. Ошибка отображается как:
Argument `#7' cannot convert `SimpleJSON.JSONNode' expression to type `System.Collections.Generic.List<string>'
Мой класс обработчика данных Json указан ниже
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class Handlepojo
{
public int astid;
public string prdname;
public int catid;
public string catname;
public string catdesc;
public int prdprice;
public List<string> Urls;
public Handlepojo(int assetid, string productname, int categid, string categoname, string categodesc, int productprice, List<string> Allurls)
{
this.astid= assetid;
this.prdname = productname;
this.catid = categid;
this.catname = categoname;
this.catdesc = categodesc;
this.prdprice = productprice;
this.Urls = Allurls;
}
}
Ниже показано, как добавить данные JSON в один список.
for (int i = 0; i < JNode.Count;i++)
{
Alldetails.Add(new Handlepojo(JNode[i]["id"], JNode[i]["product_name"], JNode[i]["product_category_id"], JNode[i]["product_category_name"],
JNode[i]["product_description"], JNode[i]["product_price"],JNode[i]["product_images"]));
}
Мое значение JSON выглядит следующим образом
{
"id": 1,
"product_name": "Wood Chair",
"product_category_id": 3,
"product_category_name": "Chair",
"product_description": "Tough Hard wood",
"product_price": "100",
"product_images":
[
"http://test.com/testing/storage//productphotos/HYTh3zUYjQKuHavNSpjQ1xeUq7laeS1WwOKPOkpQ.jpeg",
"http://test.com/testing/storage//productphotos/h01SOXObWmF07OCKesMFOacK4LRCpU8Rl14T6b1Z.jpeg",
"http://test.com/testing///productphotos/cWQG7Xpkdhht1218xg5gPYaYDoi6pJPzt7MDhBqY.jpeg",
"http://test.com/testing///productphotos/P64UvFr7vQidwSkKvGQjwebSCOAoHCXLfxijtPND.jpeg",
"http://test.com/testing///productphotos/tKt8rf0FYHqYFlqMD3tqgTydqRYMFeKZBZiP7oMN.jpeg"
]
}
Но в последней строке отображается ошибка Jnode ["product_images"]
" cannot convert `SimpleJSON.JSONNode' expression to type `System.Collections.Generic.List<string>' . "
Как добавить их в один список?Для этого я использую другой список, а затем добавляю в соответствии с ассемблером и соответствующими URL-адресами. Почему я не могу добавить JSONarray в виде строки в список, используя SimpleJson?