Send NSMutableArray as JSON using JSON-Framework

后端 未结 3 1647
无人共我
无人共我 2021-01-19 14:08

I\'m using JSON-Framework in my project successfully to decode JSON send from a server.

Now I need to do it the other way around and I\'m facing problems as the data

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-19 14:27

    Allow me to suggest a somewhat nicer solution:

    In your MenuItems class, implement the -proxyForJson method and you should then be able to call the -JSONRepresentation method directly on the menuItems array.

    @interface MenuItems(SBJson)
    -(id)proxyForJson {
        return [NSDictionary dictionaryWithObjectsAndKeys:
                self.id,@"id",
                [self.modified description],@"modified",
                nil];
    }
    @end
    

    Hope this helps!

提交回复
热议问题