I am working on converting a string into json format and sending the json formatted data to the server.Everything is working fine. I tested the project and exported the project.Current version of Unity I am using is Unity 5.3.5.
the problem is that when I imported this project package in Unity 4.7. Iam getting an error
"The name "JsonUtility" does not exist in the current context"
How can I resolve this issue by replacing with other function so as that get worked with Unity 4.7
Here is piece of code is used for converting into json format
using UnityEngine;
using System.Collections;
using LitJson;
//using SimpleJSON;
using System.IO;
public class JsonScript : MonoBehaviour {
JsonData json;
void Start()
{
Data1 data = new Data1();
data.command = "state";
data.payload = new Payload1() { text = "wwwwwww", image = "hello" };
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 Payload1
{
public string text;
public string image;
}
[System.Serializable]
public class Data1
{
public string command;
public Payload1 payload;
}