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 ?
-
1Why don't you save them just one by one in an key/value table?Jan– Jan2012年11月21日 08:29:06 +00:00Commented Nov 21, 2012 at 8:29
-
1they are alot .. this approach is so ugly ... thanks sir!Hilmi– Hilmi2012年11月21日 08:33:52 +00:00Commented Nov 21, 2012 at 8:33
3 Answers 3
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)
3 Comments
Many people use Json.net for serialization
var log = JsonConvert.DeserializeObject<YourObject>(logJson)
and the other direction
var logJson = JsonConvert.SerializeObject(log);
Comments
You can use $.parseJSON, try this just for you to see the txt data:
var info = $.parseJSON(data);
alert(info);
4 Comments
Explore related questions
See similar questions with these tags.