开发者

Is there an equivalent to Colander/DictShield for Java/Scala?

开发者 https://www.devze.com 2023-03-21 09:42 出处:网络
Colander is a Python Pylons tool used to: validate and deserialize data obtained via XML, JSON, an HTML form post or any other equally simple data serialization

Colander is a Python Pylons tool used to:

validate and deserialize data obtained via XML, JSON, an HTML form post or any other equally simple data serialization

It's kind of like an ORM for semi-structured data; to my mind it would be particularly useful if you're dealing with either:

  1. Lots of third开发者_如何转开发-party APIs returning XML/JSON in proprietary structures
  2. An internal system which needs to serialize and de-serialize the same data (e.g. if you have an internal API to bridge)

I'm working on a Scala project which has both of those requirements - and so I was wondering if there's any equivalent to Colander being worked on for JVM?


Simple is very similar to XStream, but simpler to use.


XStream may be a good choice for such a library


For completeness: I ended up going with JAX-RS/JAXB/Jackson. All of the work I wanted to do with de/serialization was related to RESTful APIs, so it made sense to go with a stack that handled more than just the marshalling. I'm finding it very good to work with - especially as it interoperates with Akka Mist out of the box.

Here are some Stack Overflow posts which were helpful background for me:

  • JAX-RS Frameworks
  • Scala framework for a Rest API Server?
  • Java- Jersey, JAX RS

Another alternative is Parboiled, from the creator of Scala's Spray framework.

For any Pythonistas who come across this question, it's worth noting an alternative to Colander is DictShield, from the creator of the async framework Brubeck.

I guess I've learnt that good text serialization/deserialization is typically just a component of larger stacks/frameworks.

0

精彩评论

暂无评论...
验证码 换一张
取 消