Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert class object to JSon string in Unity3D?

I'm using SimpleJSON, and I am kinda new to json.

For some reason, no one on google mentions how to convert objects to json strings. They just all say deserialize json strings, or give you an already made json string. Even SimpleJSON's documentary doesn't mention it. Why is that?

This is my code. Does anyone know what is the code to convert stuff to a json string?

[System.Serializable]
public class Skill
{
    public bool crush = false;
    public bool parry = false;
    public bool slam = false;
    public bool magic = false;
    public bool evadeUp = false; 
}

public Skill[] allSkills;
like image 414
BenShuu Avatar asked Jan 07 '14 08:01

BenShuu


1 Answers

Using Newtonking's JSON parser you can drag the dll into your Plugins folder and reference it (using Newtonsoft;) from there, it's one of the best serialisers I've seen online, I highly recommend using it:

http://james.newtonking.com/json

like image 181
Tom 'Blue' Piddock Avatar answered Sep 23 '22 01:09

Tom 'Blue' Piddock