sbjson

Objective-C - How to convert NSString to escaped JSON string?

老子叫甜甜 提交于 2019-12-19 03:55:10
问题 I have a NSString that may contain quotes,\, /, \r, \n, and I want to convert it to a JSON encoded string so strings like this "text1\text2" becomes \"text1\\text2\" Is there a existing function to let me do this? Also, I am using SBJson in my project but I cannot find whether SBJson can do this or not. NSJSONSerialization is not on the table since my application still needs to support OSX 10.6 回答1: Does this answer your question? -(NSString *)JSONString:(NSString *)aString { NSMutableString

Incorrectly parse json into NSDictionary

独自空忆成欢 提交于 2019-12-13 03:35:50
问题 I am trying store text fields data into a NSDictionary from json. I have used SBJson for this. { "fields":[ { "textFields":[ { "text":"Congratulations", "textSize":"12" }, { "text":"Best Wishes", "textSize":"15" }, { "text":"Test text", "textSize":"10" } ] }, { "imageFields":[ { "image":"test1.jpg", "width":"200", "height":"100" }, { "image":"test2.jpg", "width":"200", "height":"100" } ] } ] } My code: -(void)readJson{ NSDictionary *jsonDict = [jsonString JSONValue]; NSDictionary *fieldsDict

Parsing JSON string to a NSMutableArray

為{幸葍}努か 提交于 2019-12-12 04:53:38
问题 This is my string: [{"id":"1","nome":"Adriatik"},{"id":"2","nome":"Ard"},{"id":"3","nome":"Albana"},{"id":"4","nome":"Adriana"}] I would like to parse all 'name' of the JSON string into a NSMutableArray . Sorry for my english! 回答1: Whenever I have to handle some JSON code, the first thing I like to do is create a class based on the JSON text. So, for example if your JSON is representing a U.S. state, create a "State" class. There's a cool little product that you can use for this. It's called

iphone with sbjson framework cant parse json array

喜夏-厌秋 提交于 2019-12-12 01:56:38
问题 Im facing some problem with json and objective c. Atm i am using sbJson framework (i can change framework if some tell me do it!) and im not being able to parse a json array. this is the json i want to parse, {"JsonEventosResult": [ {"nombre":"Venta de Reposición N°13","id":34,"fecha":"16/09/2011"}, {"nombre":"evento rose","id":37,"fecha":"04/10/2011"}, {"nombre":"Prueba PhoneGap","id":40,"fecha":"23/11/2011"} ] } this is my code on iphone: - (void)connectionDidFinishLoading:(NSURLConnection

Is it possible to parse an NSInputStream using SBJson4?

人走茶凉 提交于 2019-12-11 22:48:43
问题 I am trying to a read JSON file containing contact info objects consisting of NSString types and NSMutableArrays. Currently, I am using NSData to read the whole file and then parsing through it. I have utilised Stig's example as mentioned here: SBJson4Parser Example SBJson4ValueBlock block = ^(id obj, BOOL *stop) { NSLog(@"Found: %@", @([obj isKindOfClass:[NSDictionary class]])); //contactsData *contact = obj; NSDictionary *contact = obj; NSLog(@"Contact: %@",contact); /* NSString *fName,

parsing json - reached max depth

梦想的初衷 提交于 2019-12-11 09:33:57
问题 I want to parse the comments of a reddit post with over 500 comments. For example this one: http://www.reddit.com/comments/xu11o The json url is: http://www.reddit.com/comments/xu11o.json In am using SBJson to achieve this. When I try to get a NSArray with this code: NSString* response = [request responseString]; NSArray* responseArray = [response JSONValue]; I get this error message: -JSONValue failed. Error is: Input depth exceeds max depth of 32 Changing the depth to a higher number of for

iOS objective-c - JSON String to NSDictionary Exception

邮差的信 提交于 2019-12-11 02:32:28
问题 I'm relatively new to Objective-C, and followed a tutorial on an introduction to MapKit (located here). I've been trying to debug an issue with a JSON string being passed to an NSDictionary. I'm getting the following error: 2012-08-13 11:18:30.370 ArrestsPlotter[76578:c07] -[__NSCFString JSONValue]: unrecognized selector sent to instance 0x73a6400 2012-08-13 11:18:30.372 ArrestsPlotter[76578:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_

NSManagedObject to JSON

不羁岁月 提交于 2019-12-10 21:49:27
问题 I have an entity class called catObras, and it inherits from the class NSManagedObject. What I want to do is pass it trough a web service (POST) in JSON form. If I sent the object I receive this: <catObras: 0x6d879f0> (entity: catObras; id: 0x6d859b0 <x-coredata://41B60B06-248C-488D-A14C-894E04D0395F/catObras/p2> ; data: { Reporte = "<relationship fault: 0x6d9dc40 'Reporte'>"; calendarioVisitas = "<relationship fault: 0x6dac2c0 'calendarioVisitas'>"; catFondosInversion = "<relationship fault:

Using SBJson with facebook sdk static library

青春壹個敷衍的年華 提交于 2019-12-10 12:07:45
问题 At the moment when I try to have the SBJson library alongside the facebook-ios-sdk I get 'duplicate interface definition for class 'SBJsonParser'' come up. So I have created a static facebook-ios-sdk library and then I have also got my standard SBJson library in the same project. I get the error. Can anyone suggest a way to fix this? I really need to use that library in my application... as I already have a good few thousand lines of code in this library and need to implement facebook too...

Display records of next page in json in uitableview on scrolling the tableView when I reach the last record

柔情痞子 提交于 2019-12-10 00:08:19
问题 I am trying to make an application that uses SBJSON and ASIHTTPRequest containing 273 pages (50 records in each page)in json. When I scroll the tableView I want to get next 50 records when I reach the last record.Currently I am getting only the first 50 records. How will I get all the records? I am using Xcode 6 objective c. //Here I am taking the json data on view load - (void)viewDidLoad { [super viewDidLoad]; main_array = [[NSMutableArray alloc] init]; NSURL *countryURL = [NSURL