Well, a "better" way of doing this would be to use a Json library. If this is in the context of an Asp.Net website (in the latter versions), there is the Json.Net library that is automatically referenced. If not, you can use Nuget to add a reference to your project or manually add it, whichever your prefer. You could then do:
JsonConvert.SerializeObject(new { longUrl = longUrl });
Note that you can also just use new { longUrl }
and the property name will be the same as your variable name.