Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 

JSON Encoder

A simple Category Class that extends NSData, NSString & NSDictionary for converting JSON objects from one type to another in one-liners.

Getting Started

Simply drop the JsonEncoder.h and JsonEncoder.m into your project.

Examples

NSDictionary

// A simple initialized dictionary
NSDictionary * dict = [NSDictionary dictionaryWithObjectsAndKeys:
                            @"Value",@"Key", nil];
// Using the extended class..
NSString * json_str = [NSString stringFromDictionary:dict];
// OR
NSData * data = [NSData dataFromDictionary:dict];

NSString

// A string that we want to convert to a dictionary
NSString * json_str = @"{\"Key\":\"Value\"}";
// Using the extended class..
NSDictionary * dict = [NSDictionary dictionaryFromString:json_str];
// OR
NSData * data = [NSData dataWithString:json_str];

NSData

// Let's assume we already have an NSData object!
// We can convert it using the extended class..
NSDictionary * dict = [NSDictionary dictionaryFromData:data];
// OR
NSString * json_str = [NSString stringFromData:data];

About

Json encoder for NSString, NSData & NSDictionary

Resources

License

Releases

No releases published

Packages

No packages published