Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

unity get json value

You can use LitJson, it is easy to use and easy to install.

Go to this link and download and import the .unitypackage into Unity:
https://github.com/Mervill/UnityLitJson

Demo code (c#):

using LitJson;

public class myClass : MonoBehaviour
{
	private void Start()
    {
    	string jsonString = "{ "distanceThisMonth": { "jeff": 56, "lizibod": "206.02" }, "distanceThisWeek": { "jeff": 13, "lizibod": "37.36" }, "stepsThisMonth": { "jeff": 94838434, "lizibod": "316812" }, "stepsThisWeek": { "jeff": 235642, "lizibod": "57331" } }";
    
    	JsonData json = JsonMapper.ToObject(a JSON string);
        
        Debug.Log(json["distanceThisMonth"]["jeff"].ToString()); //returns 56
        Debug.Log(json["stepsThisMonth"][1].ToString()); //returns 316812
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: angular findindex object based array 
Javascript :: retrieve data from option select js 
Javascript :: using async in useeffect 
Javascript :: javascript scroll to top 
Javascript :: particles js is not full screen 
Javascript :: javascript easiest way to get second parent 
Javascript :: how to loop an object in javascript 
Javascript :: merge objects javascript 
Javascript :: ajax onchange dropdown 
Javascript :: moment timezone set default timezone 
Javascript :: javascript timeout 
Javascript :: js get url variables 
Javascript :: javascript right trim 
Javascript :: to uppercase js 
Javascript :: how to customize js alert box 
Javascript :: json data sample 
Javascript :: node js cross origin error 
Javascript :: create react native 
Javascript :: how to check localstorage not set 
Javascript :: bootstrap datepicker mindate today 
Javascript :: rating star jquery 
Javascript :: useparams example 
Javascript :: count array filter javascript 
Javascript :: disable mixed content via javascript 
Javascript :: datepicker jquery year range 
Javascript :: js set datetime 
Javascript :: javascript response redirect 
Javascript :: isotope cdn 
Javascript :: Check object property exists or not in js 
Javascript :: js get first element of array 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =