Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
please help me out from this problem
Posted
Comments
Maciej Los 7-May-15 8:02am    
Not a question at all!

1 solution

Try this:
XML
public JsonResult ReturnJsonValues()
        {
            // Creted XML object
            var xml =
      @"<Columns>
          <Column Name=""key1"" DataType=""Boolean"">True</Column>
          <Column Name=""key2"" DataType=""String"">Hello World</Column>
          <Column Name=""key3"" DataType=""Integer"">999</Column>
        </Columns>";

            // conver xml to Jcon
            var dic = XDocument
                .Parse(xml)
                .Descendants("Column")
                .ToDictionary(
                    c => c.Attribute("Name").Value,
                    c => c.Value
                );
            var json = new JavaScriptSerializer().Serialize(dic);

            // Return the Json object using asp.net MVC

            return Json(json, JsonRequestBehavior.AllowGet);
        }



I hope this will help .. :)

Thanks,
Bimal
 
Share this answer
 
v2
Comments
Maciej Los 7-May-15 8:06am    
+5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900