Git Product home page Git Product logo

Comments (3)

ManueGE avatar ManueGE commented on September 27, 2024

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.

markkrenek avatar markkrenek commented on September 27, 2024

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.

gonzalezreal avatar gonzalezreal commented on September 27, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.