-2

I have a Class as follows

Class1 *obj = [[Class1 alloc] init];
obj.id=1;
obj.Name=@"aaa";
obj.Marks=100;

I am adding this to NSMutableDictionary as follows

NSMutableDictionary* dict=[[NSMutableDictionary alloc]initWithCapacity:10];
[dict setObject:obj forKey:"1"];

So If I serialize dict object I'll get

{ 1:{id:1,Name:"aaa",Marks:100},2:{"id:2,Name:"bbb",Marks:70} }

How Can I Serailize dict object into JSON like above ?

Thanks in Advance

rmaddy
  • 314,917
  • 42
  • 532
  • 579
user2970535
  • 91
  • 1
  • 6
  • 2
    See http://stackoverflow.com/questions/19459750/serialize-custom-object-to-json-which-contains-nsmutablearray?rq=1 – rmaddy Nov 09 '13 at 01:37

1 Answers1

-1

Use dataWithJSONObject:options:error: method of NSJSONSerialization class.

Roshan
  • 1,937
  • 1
  • 13
  • 25
  • NSJSONSerialization documentation clearly states that "All objects are instances of NSString, NSNumber, NSArray, NSDictionary, or NSNull.". this does not answer the posed question. – Brad Allred Nov 09 '13 at 05:02