I really need to read the Json data from : https://api.iextrading.com/1.0/stock/aapl/batch?types=quote,news,chart&range=1m&last=10
Unfortunately because I am a beginner I don't really understand the reference documentation about Json Utility. Can someone please help me passing the data from Json to c#.
Json data :
{
"quote": {
"symbol": "AAPL",
"companyName": "Apple Inc.",
"primaryExchange": "Nasdaq Global Select",
"sector": "Technology",
"calculationPrice": "close",
"open": 189.1,
"openTime": 1526304600392,
"close": 188.15,
"closeTime": 1526328000294,
"high": 189.53,
"low": 187.86,
"latestPrice": 188.15,
"latestSource": "Close",
"latestTime": "May 14, 2018",
"latestUpdate": 1526328000294,
"latestVolume": 15201663,
"iexRealtimePrice": 188.17,
"iexRealtimeSize": 100,
"iexLastUpdated": 1526327999941,
"delayedPrice": 188.15,
"delayedPriceTime": 1526328000294,
"previousClose": 188.59,
"change": -0.44,
"changePercent": -0.00233,
"iexMarketPercent": 0.03066,
"iexVolume": 466083,
"avgTotalVolume": 34166845,
"iexBidPrice": 0,
"iexBidSize": 0,
"iexAskPrice": 0,
"iexAskSize": 0,
"marketCap": 924783214700,
"peRatio": 19.34,
"week52High": 190.37,
"week52Low": 142.2,
"ytdChange": 0.10092655711038234
}
}
I started writing some code to get the json string but i am not able to parse it.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
public class DataManager : MonoBehaviour
{
public string Index_name;
public string URL;
public string jsonString;
// Update is called once per frame
void Update()
{
URL = "https://api.iextrading.com/1.0/stock/" + Index_name + "/batch?types=quote,news,chart&range=1m&last=10";
}
public void Text_Changed(string newIndex)
{
Index_name = newIndex;
}
public void Request()
{
WWW request = new WWW(URL);
StartCoroutine(OnResponse(request));
}
private IEnumerator OnResponse(WWW req)
{
yield return req;
jsonString = req.text;
}