Actually I am using Json.net for serializing the object into a json string, in that i faced a suituation in which i want to serialize the object without the {} in my Json String. Is there any way to do that..
Example: Here is the class
public class Sample
{
public String name{get;set;}
public int id{get;set;}
}
While serializing the object of the above class, I get something like below
{"name":....,
"id":...}
But I dont want those {} wrapping around the json string.
I need as below,
"name":....,
"id":...
So is there any way in json.net to remove them or am i need to do it using String operations?
For Example:
My two classes are as follow,
pulbic class Class1
{
public String prop1{get;set;}
public String prop2{get;set;}
public Class2 classprop{get;set;}
}
public class Class2
{
public String prop3{get;set;}
public String prop4{get;set;}
}
When I am creating the object for class Class1 as follow and serialize i am getting the json string as follow,
Class1 c1=new Class1(){prop1="hi",prop2="hey",classprop=new Class1(){prop3="bye";prop4="byyyyye"}
{
"prop1":"hi",
"prop2":"hey",
"classprop":{
"prop3":"bye",
"prop4":"byyyyye"
}
}
But i need the string as follow,
`{
"prop1":"hi",
"prop2":"hey",
"prop3":"bye",
"prop4":"byyyyye"
}`
Do you have any way solve this situation??
"name": "value", "id": 5is not valid JSON at all.