标签: jsonkit

无法找到keyPath的对象映射:''

我正在尝试使用RestKit与提供新闻项的Web服务进行通信.我已经研究过这段文档,并基于编写此代码

//
//  NewsViewController_iPhone.m

#import "NewsViewController_iPhone.h"
#import <RestKit/RestKit.h>
#import <RestKit/CoreData/CoreData.h>
#import "NewsPost.h"

@implementation NewsViewController_iPhone

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        RKObjectManager* manager = [RKObjectManager objectManagerWithBaseURL:@"http://192.168.0.197:3000"];

        RKObjectMapping* newsPostMapping = [RKObjectMapping mappingForClass:[NewsPost class]];
        [newsPostMapping mapKeyPath:@"title" toAttribute:@"title"];
        [newsPostMapping mapKeyPath:@"body" toAttribute:@"body"];
        [newsPostMapping mapKeyPath:@"image" toAttribute:@"image"];
        [newsPostMapping mapKeyPath:@"date" toAttribute:@"date"];

        [manager.mappingProvider setMapping:newsPostMapping forKeyPath:@"news_items"];

        [manager loadObjectsAtResourcePath:@"/news.json"delegate:self];
    }
    return self;
}

- (void)dealloc
{
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a …
Run Code Online (Sandbox Code Playgroud)

json objective-c ios restkit jsonkit

4
推荐指数
1
解决办法
5812
查看次数

Compiler Error with LLVM 5.1 "Deprecated isa"

I am getting compiler errors with libJSONKit and in JSONKit.m. The errors are thrown with this: "Assignment to Objective-C's isa is deprecated in favor of object_setClass()".
There is also a secondary error: "Direct access to Objective-C's isa is deprecated in favor of object_getClass()".

Any advice on workarounds or solutions?

json llvm ios jsonkit

3
推荐指数
1
解决办法
2855
查看次数

适用于iphone应用的JSONKit?

如果我们使用JSONKit从我们的php文档解析JSON,苹果会选择不允许应用程序进入应用程序商店吗?我想使用JSONSerializable,但这适用于ios5,我不会通过这样做来疏远3gs上的ios4成员.

json app-store ios jsonkit

2
推荐指数
1
解决办法
549
查看次数

将复杂的NSObject序列化为JSON模式

我有一系列NSObject我想序列化为JSON并发布到服务.最终对象由嵌套在彼此内的这些NSObject子类的几个级别组成.

这些对象中的每一个都遵循一个协议,该协议使用一个方法,该方法使用适当的密钥返回NSDictionary中的对象属性.但是,其中一些属性是其他对象,等等,使序列化有点复杂.

有没有我可以用来简化序列化最终对象的模式?使用JSONKit,似乎我需要从最深的对象单独序列化每个字典并向后工作,检查错误,然后添加到复合字符串.我知道这不可能是使用这个非常强大的库的最佳方法.欢迎提出任何建议或指导.

编辑1

JSONKit GitHub URL

JSONKit自述文档

json ios jsonkit

2
推荐指数
1
解决办法
6129
查看次数

你如何从AFNetworking和AFJSONRequestOperation获得可变的词典?

我使用JSONKit与AFNetworking的AFHTTPClient(与AFJSONRequestOperation),我似乎无法找出一个可以如何触发使用mutableObjectFrom的... JSONKit的方法,而不是正常的解析器方法,返回(或阵列)JKDictionary .

这可能不修改AFNetworking吗?

cocoa-touch objective-c nsmutabledictionary jsonkit afnetworking

2
推荐指数
1
解决办法
1328
查看次数

- [NSURL _CFURLRequest]:发送到实例的无法识别的选择器

我在我的程序中使用JSONKit解析谷歌地方api但我的应用程序崩溃时出现以下错误 - [NSURL _CFURLRequest]:无法识别的选择器发送到实例

     NSString* URL = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/place/search/json?location=28.632808,77.218276&radius=500&types=atm&sensor=false&key=AIzaSyDHft2g5IDshIpXS17uOtZzkqGGgj-p1RQ"];

NSError* error = nil;
NSURLResponse* response = nil;


NSURLRequest *URLReq = [NSURL URLWithString:URL];
//[request setURL:URL];
//[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
//[request setTimeoutInterval:30];

NSData* data = [NSURLConnection sendSynchronousRequest:URLReq returningResponse:&response error:&error];

if (error)
{
    NSLog(@"Error performing request %@", URL);
    NSLog(@"%@", [error localizedDescription]);
    return;
}

NSDictionary *json = [data objectFromJSONData];

NSArray *places = [json objectForKey:@"results"];


NSLog(@"Google Data: %@", places);
Run Code Online (Sandbox Code Playgroud)

json nsurlconnection ios jsonkit google-places-api

2
推荐指数
1
解决办法
2385
查看次数

object_setClass()的性能而不是指定isa指针

我注意到了对XCode(4.6)的最新更新,我收到了关于几行的警告JSONKit.m.特别是,设置对象类的行:

dictionary->isa = _JKDictionaryClass;
Run Code Online (Sandbox Code Playgroud)

这些标记为已弃用,并注明首选方法是使用object_setClass():

object_setClass(dictionary, _JKDictionaryClass);
Run Code Online (Sandbox Code Playgroud)

当我问为什么最好只是让警告静音时,回答是:

即使新的Xcode版本抱怨,一切都运行正常,我不想:
1)测试每个项目我使用JSONKit来检查在object_setClass()后是否一切正常
2)松散的cpu周期,这就是我使用JSONKit的原因以NSJSONSerialization为例.我当前的应用程序解析权重为600K-1M的json文件

我们在这里讨论了多少性能影响?

注意:

我更感兴趣

dictionary->isa = _JKDictionaryClass VS object_setClass()

JSONKitVS NSJSONSerialization.

objective-c objective-c-runtime ios jsonkit

2
推荐指数
1
解决办法
1396
查看次数

JSONKit:更改和序列化JSON属性的值

我正在使用JSONKit将JSON字符串解析为NSDictionary:

NSDictionary *deserializedData = [jsonString objectFromJSONString];
Run Code Online (Sandbox Code Playgroud)

我的问题是:如何更改字典值并获取更改的JSON字符串?

我试过更改字典值:

[deserializedData setObject:[NSNumber numberWithInt:iRatings] forKey:@"ratings"];   
Run Code Online (Sandbox Code Playgroud)

但该应用程序崩溃了.我究竟做错了什么?

提前致谢!

iphone json objective-c jsonkit

1
推荐指数
1
解决办法
2185
查看次数

测试对象是否为JKArray

我想看看这个电话的结果:

NSDictionary *results = [jsonString objectFromJSONString];
id contacts=[[results objectForKey:@"list"] objectForKey:@"Contact"];
Run Code Online (Sandbox Code Playgroud)

返回数组或字典.

我试过这个:

    [contactdict isKindOfClass:[JKArray class]];
Run Code Online (Sandbox Code Playgroud)

但JKArray在JSONKit.m文件中静态声明,因此xcode无法看到它.

reflection objective-c jsonkit

0
推荐指数
1
解决办法
1942
查看次数

JSONKIT解析错误

我正在使用单例类从远程服务器(通过NSURLConnection)获取JSON - 除非我尝试使用JSONKit解析JSON,否则一切看起来都很好.

这是一些代码

-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
 [apiData appendData:data];  
}

-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
NSLog(@"Connection failed! Error - %@ %@",
      [error localizedDescription],
      [[error userInfo] objectForKey:NSURLErrorFailingURLStringErrorKey]);
}

-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse   *)response
{
NSHTTPURLResponse *realResponse = (NSHTTPURLResponse *)response;
if (realResponse.statusCode == 200)
{
    apiData = [[NSMutableData alloc] init];
} else {
    NSLog(@"Bad response = %i",realResponse.statusCode);
}
}

-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSString *jsonData = [[NSString alloc] initWithData:apiData encoding:NSUTF8StringEncoding];
NSDictionary *deserializedData = [jsonData objectFromJSONString];
[self.delegate dataLoaded:deserializedData]; 
}
Run Code Online (Sandbox Code Playgroud)

我得到的错误是在这一行

 NSDictionary *deserializedData = …
Run Code Online (Sandbox Code Playgroud)

json nsurlconnection ios jsonkit

0
推荐指数
1
解决办法
1907
查看次数