【发布时间】:2017-02-23 08:52:58
【问题描述】:
我正在尝试使用 Objective-C 解析 JSON 这是与我当前代码相呼应的 NSLog。
{
KnowledgeBaseEntry = {
AllowBotAccess = 1;
FulltextSearch = 1;
GroupId = "";
Id = 611552aea1fe4d789e31133d3ee77f35;
IsPublic = 1;
Languages = "";
OwnerId = 8c427d5;
ParentId = 1;
ShortcutWord = "";
Tags = "";
Title = "Another Test Cell";
Type = 1;
Value = "This <BR>Is<BR>testing";
};
},
{
KnowledgeBaseEntry = {
AllowBotAccess = 1;
FulltextSearch = 1;
GroupId = "";
Id = fc4f1a90243246bb93641b0c8db689b9;
IsPublic = 1;
Languages = "";
OwnerId = 8c427d5;
ParentId = 1;
ShortcutWord = "";
Tags = "";
Title = "Cydo Error 2";
Type = 1;
Value = "content<BR><BR>this is contenty";
};
},
{
KnowledgeBaseEntry = {
AllowBotAccess = 1;
FulltextSearch = 1;
GroupId = "";
Id = bd057d5443194d7a98c2398e07de919e;
IsPublic = 1;
Languages = "";
OwnerId = 8c427d5;
ParentId = 1;
ShortcutWord = "";
Tags = "";
Title = testkb2;
Type = 1;
Value = "test content!";
};
}
)
我需要使用 Title 来获取 Value 中的内容,以便在应用中显示。我可以访问 Title Var 但我不知道如何将两者与 NSLog 值匹配。任何帮助表示赞赏。
这是当前代码:
NSData *rGeniusData = [[NSData alloc] initWithContentsOfURL:
[NSURL URLWithString:@"http://jbbar.ml/rgenius/ipapi.php"]];
//Parse The JSON
NSError *error;
NSMutableDictionary *allKB = [NSJSONSerialization JSONObjectWithData:rGeniusData
options:NSJSONReadingMutableContainers
error:&error];
NSArray *kb = allKB[@"KnowledgeBaseEntries"];NSLog(@"AboveDP= %@", kb);
【问题讨论】:
-
你想要什么?你想匹配一个你想从 nslog 中选择你的值的值吗?
-
我已将标题导入 UITableView
-
我已将 Titles 导入 UITableView 并在选择时,我希望能够使用 Title Var 我必须与 Value 匹配,因此当我在新视图中加载时,我可以打印 Value通过它自己。 Title = "另一个测试单元"; Value = "content
这是有内容的";我现在正在使用: NSArray *kbc = [allKB[@"KnowledgeBaseEntries"] objectAtIndex:0];只得到一个结果。即: -
我如何打印单个 KnowledgeBaseEntry 中的值
标签: objective-c json