Created
October 20, 2015 20:00
-
-
Save jessgusclark/f5a255f65ea2c831d995 to your computer and use it in GitHub Desktop.
Convert Object to JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Data; | |
using System.Data.SqlClient; | |
using System.Linq; | |
using System.Web; | |
using UNCWebcomm; | |
using System.Runtime.Serialization; //Add Reference to | |
namespace NewsClasses { | |
[DataContract] | |
public class Keyword { | |
[DataMember] | |
public int Id { get; set; } | |
[DataMember] | |
public string Title { get; set; } | |
[DataMember] | |
public string Slug { get; set; } | |
[DataMember] | |
public bool Active { get; set; } | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Keyword LoadKeyword = new Keyword(); | |
MemoryStream stream1 = new MemoryStream(); | |
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Keyword)); | |
ser.WriteObject(stream1, LoadKeyword); | |
stream1.Position = 0; | |
StreamReader sr = new StreamReader(stream1); | |
string Json = (sr.ReadToEnd(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment