My favorites | Sign in
Project Logo
                
Code license: New BSD License
Labels: JSON, java, java5
Blogs:
Feeds:
People details
Project owners:
  ff...@gmx.de
Project committers:
imre.fazekas

svenson is a Java5 JSON generator/parser. It lets you convert Java object graphs into JSON and vice versa. svenson offers an API and annotations to aid you in this.

The initial code for svenson grew out of a simple generator tool class I once wrote for my projects. I wrote JSON parsing code while working on my own couchdb driver called jcouchdb. Later I decided to create a standalone svenson project because the outcome seemed to be sufficient for all kinds of scenarios not involving jcouchdb.

Features

Current release javadoc

Read more about memory consumption changes in svenson 1.3

Svenson and slf4j

Svenson now uses slf4j for logging, so you need to configure slf4j to log to your favourite logging API. see The slf4j manual for details.

If you use slf4j-log4j12, you still need a valid log4j configuration. svenson (especially parsing) will be slowed down considerably when that log4j configuration is missing.

example log4j configuration

log4j.rootLogger=ERROR, Console

# uncomment to set svenson logging to DEBUG
#log4j.logger.org.svenson=DEBUG

# log to the console
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=%-5p %c: %m%n

Maven Repository

So far I haven't been able to get the jcouchdb and svenson jars into the maven repos. If you want to use maven, you can use the following repository

    <repositories>
        <repository>
            <id>de.fforw.releases</id>
            <url>http://fforw.de/m2repo/releases/</url>
            <releases>
                <enabled>true</enabled>
                <checksumPolicy>warn</checksumPolicy>
                <updatePolicy>never</updatePolicy>
            </releases>
            <snapshots>
                <enabled>false</enabled>
                <checksumPolicy>warn</checksumPolicy>
                <updatePolicy>always</updatePolicy>
            </snapshots>
        </repository>
    </repositories>

Changelog

Changes from 1.3.4 to 1.3.5:

 * add support for non-annotation based TypeConversion. See org.svenson.JSON.registerTypeConversion(Class<?>, TypeConverter) and org.svenson.JSONParser.registerTypeConversion(Class, TypeConverter)
 * add SinkAwareJSONifier for sink based JSONifying
 * add default ignore properties. See org.svenson.JSON.setIgnoredProperties(Collection<String>)
 * change List<String> ignoredProps to Collection<String> ignoredProps to enable using Set<String> but keep source compatibility. 

Changes from 1.3.3 to 1.3.4:
 * Add a copy constructor to JSONParser that creates a copy of the JSONParser with the same config. Fixes serious bug in jcouchdb and other use cases.

Changes from 1.3.2 to 1.3.3:
 * added JSONConfig to represent both a parser and a generator config.
 * enable path matching based on previous type hint, add sub type matcher
 * took over common-beanutil-1.8 depedency from jcouchdb, refactored type conversion, Fixes Issue #5.

Changes from 1.3.1 to 1.3.2:
 * now uses slf4j as logging API
 * now available via Maven
 * support for interface based JSONifiers

Changes from 1.3.0 to 1.3.1:
 * support for streaming output 
 * added ClassNameBasedTypeMapper
 * added @JSONConverter annotation allowing you to convert bean properties
 * added PathMatcher to flexibilize type hints and type mappers. This feature was sponsored by [http://quinscape.de QuinScape]
 * about 20% better JSON parser performance when parsing into map/list graphs

Changes from 1.2.8 to 1.3.0:

 * support for object factories implementing org.svenson.!ObjectFactory
 * support for parsing JSON from a stream. 
 * large improvements on memory consumption.

Changes from 1.2.7 to 1.2.8:

 * embarassing failure to account for Beans as properties of other beans fixed. Thanks to Dave Bordoley for finding this.

See more changes in the project sources

== Improve Svenson == 
I'm always interested in getting new ideas to improve my projects, so
if your requirements are not met by svenson, you could try contacting me to give me a clearer idea of what could be added.








Hosted by Google Code