I am working on converting and displaying the JSON String with unity. I have done coding for it
using UnityEngine;
using System.Collections;
using LitJson;
using SimpleJSON;
using System.IO;
public class TestDelete : MonoBehaviour {
JsonData json;
void Start()
{
Data2 data = new Data2();
Payload2 data2 = new Payload2();
data.command = "state";
data.payload = new Payload2()
{
text = "wwwwwww",
image = "hello"
};
data2.option = new Option () {
A1 = "k",
A2 = "J"
};
string dataValue =data+ data2.ToString();
string json = JsonUtility.ToJson(data,true);
P(json + "\t\n");
}
// Use this for initialization
void P(string aText)
{
print (aText +"\n");
}
}
[System.Serializable]
public class Payload2
{
public string text;
public string image;
public Option option;
}
[System.Serializable]
public class Data2
{
public string command;
public Payload2 payload;
}
[System.Serializable]
public class Option
{
public string A1;
public string A2;
}
This code of working fine.But with the output Iam having problem.The out is displayed as follow
{
"command": "state",
"payload": {
"text": "wwwwwww",
"image": "hello",
"option": {
"A1": "", // not getting displayed
"A2": "" // not getting displayed
}
}
}
the string value A1 and A2 is not getting displayed.What will be the issue with my code.Can anybody help me sorting out this issues