Say I need to build a json string from pairs (e.g., coming from a database where the column name is the key).
Is it better/faster to:
a) create a JObject
and add the <string, JToken>
pairs (getting the tokens with the JToken.FromObject
) ; at the end call the JObject.ToString()
method
(here is it better to use the Add method or the indexer set?)
b) create a Dictionary
and add the <string, object>
pairs; at the end call the JsonConvert.SerializeObject
passing the dictionary
c) Any other way?
I'm worried about performance since this will be used multiple times per second.
Thanks in advance.