nathanday / ndjson Goto Github PK
View Code? Open in Web Editor NEWObjective-C JSON parser
Objective-C JSON parser
Could look for initWithJSONParent method or maybe jsonDeserializer:setJSONParent:
Could perhaps handle bad JSON better when not in strict mode.
A higher level of abstraction can be created to handle server request/responses. Could define a NDJSONRequest and a NDJSONMutableRequest. Programmers could either manipulate NDJSONMutableRequest's or subclass NDJSONRequest. Need to create a way for uses to simply define how the response should be handle, (which keys are handled by what kind of NDJSON parsing method.
String for example can actually be dates, need to way to be able to map that to a NSDate
The handling of the NSInvocation method of handling responses is broken, the first argument to -[NSInvocation setArgument:atIndex:] was handled incorrectly.
Though they are not used much, UTF-16 and UTF-32 are legal text encodings for JSON and added support for these shouldn't be two difficult.
This means that leading zeros will be lost.
The private function freeByte() is not recognised by the analyser as a function that free memory and so the analyser complains about possible memory leak.
Need to use #import <objc/runtime.h> for iOS
Since JSON itself is a tree currently only tree can be generated, it would be good to have some mechanism for recognising multiple references to to the some entity in the tree and remove that duplication, for example in JSON second reference to the same entity can represent as a simple id to the fully fleshed out original version.
Have a parseBytes method, which maintains state between called, remove all stream data source for NSJSON and put use local variable instead. This will make NDJSON simpler, allow it to work with NSURLConnection better and also handle zip streams better.
An array of integer could be the components of a date, or an array of strings could map to a single string for core data.
Current macros are only available on Mac, need to use the functions describe in this link
This could then be used to handle NSURLConnections and other situations.
Change set
Need some property on NDJSONRequest
Not really a serious bug but strict mode should only accept strict JSON, this is not referring to newline escape sequence \n but the actual character ASCII 0xA
Two important files are missing NDJSONSerialiser.[hm], can not get git to push them up.
propertyNamesForKeysJSONParser: doesn't work with names of array properties, only seems to work with simple value properties, may not work with object properties also
Could perhaps had call back function for creation of object to handle all sorts of odd situations.
Some methods refer to NDJSON as jsonParser as in - (id)jsonParser:(NDJSON*), should refer to NDJSON as jsonSource, perhaps change the name of NDJSON to NDJSONSource
Have a default property, so an instance of an object is created and then its default property is se with the primitive value
The word size is being considered, but it doesn't handle character with values > 255 properly
Use of exception to report failure to map property names for example.
Need to check this out and fix it if it does ignore unused objects, this will improve performance.
This is required for CoredData and so makes this a bug.
This can be confusing since the two core NDJSON objects can not work with ARC.
Let users save the context, that way they can do additional stuff before saving the context.
I would be good if we could simple add observers for particular key paths, using a delegate and selectors or maybe blocks to respond to particular JSON key paths.
Could perhaps add a foundKeyPath method to NDJSONDelegate to enable this, or alternatively a new object (probable not part of NDJSONParser cluster classes), could keep track of this.
This is even if you don't use CoreData, this is because some CoreData type are references in some of the methods.
It should be possible to start parsing JSON using event driven parsing and then switch to object generation for example.
should rename it to currentKey and make it public with a property.
Defaults to utf8
Need to use the property name from the class method straight away.
Also set the method type.
http://en.wikipedia.org/wiki/JSON-RPC, probable go straight to JSON-RPC 2.0.
Might work now, but no test.
Could have a class method ordinalPropertyName, on the class with the order property. (maybe have a default one to look for?)
A tutorial would be good but more appledoc type of inline documentation is needed, could move some of the information in the readme to the inline documentation.
A delegate for NDJSONDeserializer could do that, it could inherit NDJSONParserDelegate methods two so a delegate can listen in on what NDJSONDeserializer is getting from NDJSONParser
For custom objects the user can implement a method like jsonStringForJSONSerializer:, PLIST object can be handled inline so as not to clutter there interface with an addition method that could potentially collide with other API. CoreData could use the ManagedObjectModel class to determine how to serialise the objects.
Alternatively for custom objects could use the class methods defined in the NDJSONParser informal protocol.
Need to handle compressed JSON document, using zlib.
NDJSONRequest will parse the entire json request, for CoreData this is an issue because what you actually want put into your store is often a subtree. If we could switch between parsing to custom object to parsing to CoreData model that would provide a way to fix the issue. We can already switch from event driven parsing to another parsing method and back agains, so we just need to find a way to let the parser know the type of parsing has changes for a key. Maybe a CodeData models for keys method like the class for keys and property names for keys.
A lot of the time instead of doubles or longs we want an NSNumber object instead (this is what NDJSONParser uses to call setValue:forKey:), adding this method will also make it possible to use NSDecimmalNumber for numbers that can not be represented by float or long, which is required to support JSON correctly
Nice to have should be hard to implement. NaN shouldn't be confused with null when beginning to parse because of case difference.
Need to add a mechanism to parse only part of the tree, also parse a an error.
This can cause some issue, where previous key is used instead of current one.
Could look for an initWithJSONProperties: method or jsonDeserializer:setJSONProperties. Or could use the key value coding method setValuesForKeysWithDictionary:. Probable better to do an init method because the may reason this would be needed is when you need the properties at initialisation time for things like cluster classes.
Just need to be able to add
[urlReq setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"]
to the request
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.