I have a huge amount of customized attributes I want to save them in the DataBase, I was confused of how to store them in the database, i thought of storing them as a string separating them by
(=
=> name , value) (;
=> attribute , attribute) but the code wasn't elegant at all!
so i stat thinking of saving them as Json
string but I couldn't found a
Json to object parser
while we need only to call json()
to parse object to json string
is there a better way than using json string and is there json string parser provided ?
JSON-C implements a reference counting object model that allows you to easily construct JSON objects in C, output them as JSON formatted strings and parse JSON formatted strings back into the C representation of JSON objects. It aims to conform to RFC 7159.
jsmn (pronounced like 'jasmine') is a minimalistic JSON parser in C. It can be easily integrated into resource-limited or embedded projects. You can find more information about JSON format at json.org. Library sources are available at https://github.com/zserge/jsmn.
Convert String to JSON Object With the JObject. Parse() Function in C# The JObject class inside the Newtonsoft. Json package is used to represent a JSON object in C#.
Try to use System.Web.Script.Serialization.JavaScriptSerializer
, here is example:
var yourObject = new JavaScriptSerializer().Deserialize<YourType>(strInput)
or
var yourObject = new JavaScriptSerializer().Deserialize(strInput)
Many people use Json.net for serialization
var log = JsonConvert.DeserializeObject<YourObject>(logJson)
and the other direction
var logJson = JsonConvert.SerializeObject(log);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With