days
-1
-2
hours
-1
-2
minutes
-3
-6
seconds
0
-2
search
I triple dog dare you to try it out

Haven: A simple Kotlin library to keep your JSON data safe

Jane Elizabeth
machine learning Haven
© Shutterstock / connel

Want a safe place to manipulate your JSON data? Written in Kotlin, Haven was designed to be a simple, concise library for JSON users. Make JSON safely accessible again with Haven!

Don’t worry about being eaten by a grue; Haven is a safe space to manipulate your JSON data. Designed for simplicity and conciseness, this JSON library makes it easier than ever to access your data on the go.

The basic idea behind Haven is that dependencies are a liability. Sure, they can have their uses. But, in general, they’re often the source of a lot of stress and sticky situations. Best give the whole thing a miss.

Haven lets developers avoid unnecessary dependencies.  In fact, this library is written almost entirely without third-party dependencies! (The kotlintest testing framework is the notable exception.)

So, how does it work?

Most JSON libraries use a data-binding approach: users define an object that serves as the structure, which the library then maps JSON values onto.

Haven takes a different approach. Essentially, Haven takes a tree-model approach for dealing with JSON data. Parsed JSON data is an in-memory tree of objects that can be accessed on demand.  This means Haven is considerably faster and easier to dive into.

This approach does have downsides, namely type safety and an increased verbosity. That said, Haven minimizes these issues, leaving developers with a simpler way to manipulate their JSON data.

Haven also supports an additional approach: the data-binding style of JSON manipulation. Many other JVM libraries take this approach. However, this functionality is more of a second-class citizen and it’s build on top of the tree-model system. Developers really should use the tree-model approach first before moving on to data-binding.

Since it’s written in Kotlin, this library still provides a DSL syntax that’s as JavaScript as possible. Haven is trying to be as type safe as possible without actually making the user think about static types at all points. There are even extensive test cases, making sure developers can reduce the number of bugs and inconsistencies as much as possible.

SEE ALSO: Implementing a JSON-RPC protocol with Eclipse LSP4J

Find your own safe Haven

Want to try Haven out on your own? You can install Haven with JitPack or download the source code and build it yourself. Check out the releases page for the latest information. More information is available here.

Author
Jane Elizabeth
Jane Elizabeth is an assistant editor for JAXenter.com.

Leave a Reply

Be the First to Comment!

avatar
400
  Subscribe  
Notify of