Giter Club home page Giter Club logo

Comments (8)

emirpasic avatar emirpasic commented on May 18, 2024

@saheljalal

I think I had somewhere the idea of making serialization and deserialization (marshalling/unmarshalling) of these structures. My idea was to have that done in a binary form at first, but JSON could also be another option due to readability. Let me meditate on this and find some time, last few months have been crazy for me and I hardly found any free time.

What data structures are you using and would you like this feature for? What is the use case for JSON marshalling?

from gods.

saheljalal avatar saheljalal commented on May 18, 2024

I just discovered this library recently and am using the hashset to store identifiers to start. That list is just a []string but working with the set API is so much easier and faster at call sites and from a performance perspective I'm sure. On the outgoing interface as json, however, I am just marshaling my own struct to handle this for now but was wondering if it was something that could be done in a generic fashion in the data structure itself.

from gods.

emirpasic avatar emirpasic commented on May 18, 2024

@saheljalal

In most cases, the marshalling would have to be handled individually for most structures. They would share a common interface, but the logic would be custom for each. I think that would be a cool feature and will try to include it in this lib, once I clean up the other pull requests.

From the performance perspective, there is a penalty in this lib, because it uses interface{} types everywhere, which gets hit hard type assertion implementation in Go. I am not criticizing this lib, but one should be aware of that fact when using this lib and it's mainly due to the lack of generics (won't go there, I'll let others be opinionated on this) and, thus, having to type assert everywhere. My suggestion is to use native Go's maps with concrete types if the problem you are working on is simple. The HashSet is really a simple implementation that uses Go's native map, where key is the value as to be unique in the set and the value is empty struct{}{}.

from gods.

saheljalal avatar saheljalal commented on May 18, 2024

@emirpasic will keep that in mind going forward and hope to see this materialize in the future. I'd like to make more use of this library given its simple and intuitive interfaces compared to go's limited type offerings. If performance becomes an issue, will evaluate my options at that time. Thanks.

from gods.

lattice0 avatar lattice0 commented on May 18, 2024

I was about to ask for something like unmarshaling, it'd be very very useful

from gods.

emirpasic avatar emirpasic commented on May 18, 2024

@LucasZanella sure, marshaling (serialization) and unmarshaling (deserialization) will be implemented together

from gods.

emirpasic avatar emirpasic commented on May 18, 2024

@saheljalal @LucasZanella JSON marshalling and unmarshalling has been implemented in #53 for all data structures.

Please make note of the ToJSON and FromJSON functions from the examples and let me know if this works out for you.

from gods.

emirpasic avatar emirpasic commented on May 18, 2024

closed by #53

from gods.

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.