Forming Json Format String
c#, string.format
Solution
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.
Problem
I am using this method to form `json` string and this is working fine. But i can't handle this if it contains more properties. Is there any other better method than this? ``` string.Format("{0}{1}longUrl{1}:{1}{2}{1}{3}", "{", "\"", longUrl,"}"); ``` The output is ``` {"longUrl":"http://api.themoviedb.org/3/person/12835?api_key=2c50a994de5291887a4e062edd229a72"} ```