Alvaro Rojas
Alvaro Rojas

Reputation: 562

how convert RKObjectMapping (Reskit) to json string?

I have the following code:

NSString *url =     @"http://mysite.com"
RKURL *baseURL = [RKURL URLWithBaseURLString:url];
objectManager = [RKObjectManager objectManagerWithBaseURL:baseURL];
objectManager.client.baseURL = baseURL;
objectManager.serializationMIMEType = RKMIMETypeJSON;

NSString *token = @"Token is getting from rest API"
[[objectManager client] setValue:token forHTTPHeaderField:@"token"];  

RKClient *client= [objectManager client];     
RKRequest * therequest = [client requestWithResourcePath:@"/create"]; 


[therequest setHTTPBodyString:@"{user:user}"]; //Here receive a JSON value
[therequest setMethod:RKRequestMethodPOST];   
[therequest setDelegate:self];                               
[therequest send]; 

This code works fine... but I have a problem, I need to send to Rest API a JSON object (like String) and I have a RKObjectMapping with the values that should be sending to Rest Api.

It is possible convert a RKObjectMapping to JSON?

Upvotes: 0

Views: 192

Answers (1)

Madbreaks
Madbreaks

Reputation: 19539

You can't do it natively unless you write a JSON library yourself. Otherwise, consider leveraging something like JSONKit, it's easy to use and works well.

Here's an example usage.

Upvotes: 1

Related Questions