C
C#2y ago
Nukadelic

❔ Help needed converting anon object to JSON

My attempt :
var data = new { roomLink = roomLink, roomName = roomName, secret = secret };
Debug.Log( data );
// output : { roomLink = localhost:8338, roomName = new room name, secret = password35 }

var json = JsonUtility.ToJson( data );
Debug.Log("JSON = " + json.ToString() );
// output : JSON = {}

Debug.Log("JSON = " + UnityEditor.EditorJsonUtility.ToJson( json ).ToString() );
// output : JSON = {}
var data = new { roomLink = roomLink, roomName = roomName, secret = secret };
Debug.Log( data );
// output : { roomLink = localhost:8338, roomName = new room name, secret = password35 }

var json = JsonUtility.ToJson( data );
Debug.Log("JSON = " + json.ToString() );
// output : JSON = {}

Debug.Log("JSON = " + UnityEditor.EditorJsonUtility.ToJson( json ).ToString() );
// output : JSON = {}
1 Reply
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server