Skip to content

danboykis/trava

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Trava (Transit + Java)

Working with transit from Java is often a pain because of deeply nested datastructures that come back from transit. Trava attempts to make life a little easier by providing helper functions to access nested data.

There are things trava doesn’t do yet. For example, assoc in trava won’t work on java.util.List but even in this state I have found it useful. Pull requests are welcome.

Example

{:a {:b {:c 10}}}
//serialized clojure datastructure from above
Map<Keyword,Object> nestedMap = ... ;

List<Keyword> path = Arrays.asList(new KeywordImpl("a"), new KeywordImpl("b"), new KeywordImpl("c"));

Assert.assertEquals(10,Navigator.getIn(nestedMap, path));

//Transform the map to make it like so:
// {:a {:b {:c 10 :d 1}}}
List<Keyword> newPath = Arrays.asList(new KeywordImpl("a"), new KeywordImpl("b"), new KeywordImpl("d"));

nestedMap = Navigator.assocIn(nestedMap, newPath, 1);
Assert.assertEquals(1,Navigator.getIn(nestedMap, newPath));

About

making it easier to work with transit from java

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages