I'm getting the following JSONException when JSON serializing a Map of generic Objects which contains a Url object deeply nested within.
System.JSONException: Type unsupported in JSON: common.apex.methods.ApexUrl$URIImpl
It looks like Apex doesn't support JSON serializing the Url class because I was able to replicate the error in Anonymous Apex simply with JSON.serialize(new Url('https://www.google.com'));
.
What would be the best way to serialize my object without having to refactor my Url properties to String? For some context, I'm serializing the Map described in this question.
String
. Why do you want to leave them asURL
? You seem to be having a bit of an X-Y Problem here.