This is not the single way to serializing object into JSON, but the simple way is to do that.
1. Download the Newtonsoft JSON serializer.
2. Reference the DLL.
3. Using the namespace in your class.
C# Code.
namespace:
using Newtonsoft.Json;
public string GetData(string name)
{
person p = new person();
p.name = name;
return JsonConvert.SerializeObject(p);
}
}
1. Download the Newtonsoft JSON serializer.
2. Reference the DLL.
3. Using the namespace in your class.
C# Code.
namespace:
using Newtonsoft.Json;
public string GetData(string name)
{
person p = new person();
p.name = name;
return JsonConvert.SerializeObject(p);
}
}
No comments:
Post a Comment