Example #1
0
    public JSONObject Serialize()
    {
        var jsonObject = new JSONObject(JSONObject.Type.OBJECT);

        jsonObject.AddField("Unlocked", Unlocked.ToString());
        jsonObject.AddField("AfterLevel", AfterLevel);
        jsonObject.AddField("UnlockedLevel", UnlockedLevel);
        if (Unlocked == Unlock.Friends)
        {
            var friendsIdsObject = new JSONObject(JSONObject.Type.ARRAY);
            foreach (var friendsId in FriendsIds)
            {
                friendsIdsObject.list.Add(new JSONObject(friendsId));
            }
            jsonObject.AddField("FriendsIds", friendsIdsObject);
        }

        return(jsonObject);
    }