parse Json text to C# object in asp mvc 4

前端 未结 3 1743
情深已故
情深已故 2021-02-19 22:42

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 sep

相关标签:
3条回答
  • 2021-02-19 22:54

    You can use $.parseJSON, try this just for you to see the txt data:

    var info = $.parseJSON(data);
     alert(info);
    
    0 讨论(0)
  • 2021-02-19 23:04

    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)
    
    0 讨论(0)
  • 2021-02-19 23:10

    Many people use Json.net for serialization

    var log  = JsonConvert.DeserializeObject<YourObject>(logJson)
    

    and the other direction

      var logJson = JsonConvert.SerializeObject(log);
    
    0 讨论(0)
提交回复
热议问题