Comments (5)
I love that idea. I think it would be neat if it was something like
- (id)JSONValue;
That just returned one of the supported classes, since most of the time you would want to return a dictionary or an array or something.
from jsonkit.
How about something like:
@protocol JKCoding <NSObject>
- (id) JSONRepresentation;
- (id) initWithJSONRepresentation: (id);
@end
Remember that if we implement something like this, the JSON will just contain an array, dictionary, string, or number representation of this object. What we need to do is somehow store the class hierarchy "chain" like Apple does in its .plist
s so that we know what class we have when we're unarchiving/unserializing. The reason we store the class hierarchy is so that if the first class is unavailable we can default to the next, and so on.
Perhaps something like:
If MyArray
is an NSMutableArray
subclass, and -[MyArray JSONRepresentation]
yields @"JSON VALUE"
, we could encode it like this:
["JSON_VALUE", "MyArray", "NSMutableArray", "NSArray", "NSObject"]
.
from jsonkit.
Is there any reason why the current block / delegate pattern in place can't be used to implement this?
I don't necessarily disagree with the request. It's more a matter of finding the balance between which features should be included in the core and providing primitives that allows the end-user to easily extend the core to better fit their particular needs.
I'm of the opinion that it's far more important to provide high quality general purpose primitives that would allow a feature like this to be implemented than necessarily providing the feature itself. What's a must have feature to use is bloat to someone else. :) I think something like this would be better done in a Cookbook.md
like file that would provide patterns that others would likely find useful while at the same time serving as documentation on how to make use of the provided primitives to accomplish something.
Thoughts?
from jsonkit.
No, you're right. You have to develop for 80% of your target user base. The feature I'm describing would be for encoding entire objects, which is something that could go in a Cookbook file.
Cheers
from jsonkit.
I agree that block/delegate pattern is useful enough. However, in case there are many objects of unsupported classes, there would have many temporary NSDictionary or NSArray objects along the serialization.
Is there a way to deal with this situation?
How about an selector of the delegate that serialize the object by itself to a buffer or NSMutableData which JSONKit provided.
from jsonkit.
Related Issues (20)
- Any popular replacement for JSONKit? HOT 2
- BSD two-clause or three-clause license? HOT 2
- crash at JSONKit.m:2598:77 HOT 2
- Error in serializing NSNumber HOT 2
- Supporting gzip decompression
- Swift HOT 7
- can not use with xcode 7 HOT 4
- Xcode 7 Before is use JSONKit in Object but now not use JSONKit in Xcode 7 HOT 7
- crash with iOS9 Xcode7 HOT 5
- Should be #import <JSONKit/JSONKit.h> or <GCJSONKit/JSONKit.h>? HOT 1
- please ignore
- Crash when NSDictionary to String json format. HOT 1
- about convert json to NSDictioanry (error if json string contains double field) HOT 7
- JsonKit message JSONDataWithOptions crashes in macOS Sierra HOT 1
- JSONKit Installation error in X-code 7.3.1 iOS 9.3 HOT 1
- iOS TRAP_TRACE crash
- JSONKit semantic issue after updating the pod HOT 3
- Tagged pointer format changes in iOS 14 break JSONKit on ARM64 HOT 8
- @serkrapiv Not necessarily verboten, just that they must be escaped. The first paragraph of 2.5 Strings says: HOT 1
- Yea
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsonkit.