json-framework

Send NSMutableArray as JSON using JSON-Framework

☆樱花仙子☆ 提交于 2019-12-01 22:04:46
问题 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 to be sent is a NSMutableArray fetched from CoreData. When using NSString* jsonString = [menuItems JSONRepresentation] I get the message "JSON serialisation not supported for MenuItems". Do I need to convert the NSMutableArray to some other format so the JSON-Framework can serialize it? Thanks for any help, Miguel 回答1: Allow me to

Send NSMutableArray as JSON using JSON-Framework

梦想与她 提交于 2019-12-01 18:30:54
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 to be sent is a NSMutableArray fetched from CoreData. When using NSString* jsonString = [menuItems JSONRepresentation] I get the message "JSON serialisation not supported for MenuItems". Do I need to convert the NSMutableArray to some other format so the JSON-Framework can serialize it? Thanks for any help, Miguel Stig Brautaset Allow me to suggest a somewhat nicer solution: In your MenuItems class, implement the -proxyForJson

Replace all NSNull objects in an NSDictionary

≯℡__Kan透↙ 提交于 2019-11-27 03:28:42
I'm curious, I currently have an NSDictionary where some values are set to an NSNull object thanks to the help of json-framework. The aim is to strip all NSNull values and replace it with an empty string. I'm sure someone has done this somewhere? No doubt it is probably a four liner and is simple, I am just far too burnt out to figure this out on my own. Thanks! Really simple: @interface NSDictionary (JRAdditions) - (NSDictionary *)dictionaryByReplacingNullsWithStrings; @end @implementation NSDictionary (JRAdditions) - (NSDictionary *)dictionaryByReplacingNullsWithStrings { const

Replace all NSNull objects in an NSDictionary

徘徊边缘 提交于 2019-11-26 10:29:39
问题 I\'m curious, I currently have an NSDictionary where some values are set to an NSNull object thanks to the help of json-framework. The aim is to strip all NSNull values and replace it with an empty string. I\'m sure someone has done this somewhere? No doubt it is probably a four liner and is simple, I am just far too burnt out to figure this out on my own. Thanks! 回答1: Really simple: @interface NSDictionary (JRAdditions) - (NSDictionary *)dictionaryByReplacingNullsWithStrings; @end