- Home /
How to slice JsonData Array in unity?
Hi Guys,
I'm retriving data from server. Data is in JsonData array. I can retrive single value but not able to retrive array. when i retrive array it just prints its data type. I want to slice array into various arrays.
Anybody knows how to do it?
This is script to parse json data
using System; using System.Collections;
public class JsonParse : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public string json_parse(string jsonString)
{
JsonData jsonBooks = JsonMapper.ToObject(jsonString);
return (jsonBooks["status"].ToString());
// if(id == "true") // { // call = true; // art = jsonBooks["artwork_url"].ToString(); // } }
public string _Value( string jsonString)
{
JsonData _value = JsonMapper.ToObject(jsonString);
return(_value["value"].ToString());
}
public string _LocationId( string jsonString)
{
JsonData _locationId = JsonMapper.ToObject(jsonString);
return(_locationId["locationId"].ToString());
}
//Here i m getting array which i want to sllice into various arrays
// array looks like "details" : [{"id" : "a12","title" : "title1","url" : "url" }{}....{} ]
public object[] _GetProducts( string jsonString)
{
JsonData _getProducts = JsonMapper.ToObject(jsonString);
return(_getProducts["details"]);
}
}
What's "Json$$anonymous$$apper"? It seems you use a 3rd party class. I guess you use LitJSON, in this case the documentation of this library should be enough.
I m getting array which is JsonData array. I want to retrive value of objects in array one by one. I want to access object data such as product_id, title from object. How to do it?
Your answer
Follow this Question
Related Questions
Help using LitJson 1 Answer
Constructing object array with JsonUtility 1 Answer
SimpleJSON get Array lenght ? 2 Answers
¿ Porque no me funciona el FromJSON ? 0 Answers
JSON missing arrays 1 Answer