Comments (3)
I had to handle with this issue in some of my apps. This is the way I solved it.
First, I created a NSManagedObject
category with two methods:
+ (instancetype) grt_mergeObjectFromJSONDictionary:(NSDictionary *) dictionary
inManagedObjectContext:(NSManagedObjectContext *)context
error:(NSError **) error;
+ (NSArray *) grt_mergeObjectsFromJSONArray:(NSArray *)array
inManagedObjectContext:(NSManagedObjectContext *)context
error:(NSError *__autoreleasing *)error;
In its implementation, I call the Groot methods.
When I want to parse a JSON, I use always this category instead of the Groot methods. If one of my entities needs a post-processing, I just override this methods and perform the post-process there.
If you like this idea, I can provide the full code of the category.
from groot.
Interesting. Those merge function are from an older version of Groot, right? I'm using GRTJSONSerialization.objectsWithEntityName to fire off a big chain of serializations which ultimately calls grt_serializeJSONDictionary for each managed object. I need to look into having my subclasses of NSManagedObject override grt_serializeJSONDictionary. I'm using Swift.
from groot.
I would have thought that use case is covered by returning the serialized managed objects.
I will consider having methods that take a block for post-processing if that's not enough. Any other ideas are welcome.
from groot.
Related Issues (20)
- Ralationships with objects
- Swift3 HOT 3
- Update NSManagedObject with JSON
- Add relationships by merging with existing ones HOT 2
- Groot.swift compile errors
- Xcode 8 \ Swift 2.3 Support
- Groot cannot parse HOT 1
- Question About Concurrency Type for Context HOT 2
- Ambiguous use of jsonDictionary(from:) HOT 1
- How to use ValueTransformer in swift3? can you give me a sample pplease HOT 5
- Could not locate the entity for myappTests.Example when inside XCTestCase HOT 1
- Prevent infinite recursion when Groot traverses complex data model? HOT 6
- 【JSONKeyPath】
- GRTUniquingSerializationStrategy: attribute with null value replaces original value HOT 3
- Serialised output field names not in quotes HOT 2
- Could not locate the entity for \(className) even though it exists HOT 5
- Parsing Boolean value fails
- Ability to modify objects after being imported using Groot HOT 2
- Automatically mapping properties with the same name
- how to convert Json to JsonDictionary?
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 groot.