Quantcast
Channel: Questions in topic: "webgl"
Viewing all articles
Browse latest Browse all 2390

[WEBGL] Post json - complicated structure

$
0
0
Good Day , I have problem with sending json data. When i have simple structure like: { "email": "string", "password": "string" } its not a problem. I can use : WWWForm wwwForm = new WWWForm (); wwwForm.AddField ("email", login); wwwForm.AddField ("password", password); WWW www = new WWW (baseURL+loginURL, wwwForm); yield return www; and its working. But i dont know what to do when i have structure like this: { "resource": [ { "user_id": 0, "name": "string", "value": "string" } ] } I was trying by www class and by UnityWebRequest and no success.... Can anyone help me? Show me the way to the light :) EDIT. SOLUTION::: I found solution for my problem: string json = "{'resource':["+ "{" + "'BoatName':'" + boatName + "'," + "'BoatType':'" + boatType + "'," + "'BoatColorTop':'" + boatColorTop + "'," + "'BoatColorBottom':'" + boatColorBottom + "'," + "'BoatColorStripe':'" + boatColorStripe + "'," + "'TowerType':'" + towerType + "'," + "'TowerColor':'" + towerColor + "'," + "'Engine':'" + engine + "'," + "'Package':'" + package + "'" + "}]}"; json = json.Replace("'","\""); Dictionary headers = new Dictionary(); headers.Add (apiKeyHeader, apiKey); headers.Add (sesionTokenHeader, sesionToken); headers.Add ("Content-Type", "application/json"); byte[] body = Encoding.ASCII.GetBytes(json); WWW www = new WWW (baseURL + dataBaseURL, body, headers); yield return www; var result = JSON.Parse (www.text); print ("Success: " + result);

Viewing all articles
Browse latest Browse all 2390

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>