Skip to content

doanthegiang/ParseJSON

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ParseJSON

Hello guys! This is Parsing JSON method by Giang Doan

Use

  1. Method: (NSDictionary *) convertObjectToDictionary: (id) object
  • Convert Object to NSDictionary if you are lazy to do it because it's so long or so params.

Example:

Create modal

@interface Demo: NSObject
@property (weak, nonatomic) NSString *id;
@property (weak, nonatomic) NSString *gender;
@property (weak, nonatomic) NSString *avatar;
@end

Use method:

NSDictionary *demo = [Demo convertObjectToDictionary: [[Demo alloc] init]];

Result

{
    avatar = "https://github.com/doanthegiang/ParseJSON.git";
    gender = name;
    "user_name" = giang;
}

  1. Method: (void) parseDictionaryToObject: (NSDictionary *) dictionary
  • Convert JSON to Object (before you make do it allow so you just convert JSON to NSDictionary)

Example:

Create modal

@interface Demo: NSObject
@property (weak, nonatomic) NSString *id;
@property (weak, nonatomic) NSString *gender;
@property (weak, nonatomic) NSString *avatar;
@end

Use method

@{
        @"id": @"1000",
        @"gender": @"10",
        @"avatar": @"giang"
}

Use method:

Demo *c = [[Demo alloc] init]; // init model
[c parseDictionaryToObject:[self initializationDictionary]];

Sorry, my english is like shit!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published