© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
1 reply
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 = {}
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Ocelot json Help needed
C#CC# / help
3y ago
Converting ReadOnlySequence of bytes to object
C#CC# / help
4y ago