Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

2011-07-11

Gson v Jackson - Part 6

tl;dnr

Use Jackson, not Gson. Use this article as a reference for basic features.

Part 5 of this short series of articles ended with section 5.17 of the Gson user guide, "Streaming". (Sections 6 and 7 will not be reviewed.) This sixth part includes a summary of the key differences between Gson and Jackson noted so far, along with a table of contents listing for easy navigation to the various sections of this review.
Link To This ArticleQR Code Link To This Articlehttp://goo.gl/0oR3t

2011-07-10

Gson v Jackson - Part 5

tl;dnr

Use Jackson, not Gson. Use this article as a reference for basic features.

Part 4 of this short series of articles ended with section 5.14.3 of the Gson user guide, "User Defined Exclusion Strategies". This fifth part continues with section 5.15 on "JSON Field Naming Support", and ends with section 5.17 on "Streaming", which is the end of the Gson user guide. Part 6 will include a summary of the key differences between Gson and Jackson noted so far, along with a table of contents listing for easy navigation to the various sections of this review.
Link To This ArticleQR Code Link To This Articlehttp://goo.gl/fWihj

2011-07-03

Gson v Jackson - Part 4

tl;dnr

Use Jackson, not Gson. Use this article as a reference for basic features.

Part 3 of this short series of articles ended with section 5.10.1 of the Gson user guide, "InstanceCreator for a Parameterized Type". This fourth part continues with section 5.11 on "Compact Vs. Pretty Printing for JSON Output Format", and ends with section 5.14.3 on "User Defined Exclusion Strategies". Part 5 will continue with section 5.15 on "JSON Field Naming Support".
Link To This ArticleQR Code Link To This Articlehttp://goo.gl/RpFIE

2011-07-02

Gson v Jackson - Part 3

tl;dnr

Use Jackson, not Gson. Use this article as a reference for basic features.

Part 2 of this short series of articles ended with section 5.7 of the Gson user guide, titled "Serializing and Deserializing Collection with Objects of Arbitrary Types". This third part continues with section 5.8 on "Built-in Serializers and Deserializers", and ends with section 5.10.1 on "InstanceCreator for a Parameterized Type". Part 4 will continue with section 5.11 on "Compact Vs. Pretty Printing for JSON Output Format".
Link To This ArticleQR Code Link To This Articlehttp://goo.gl/HsIea

2011-06-27

Gson v Jackson - Part 2

tl;dnr

Use Jackson, not Gson. Use this article as a reference for basic features.

Part 1 of this short series of articles ended with section 5.3 of the Gson user guide, titled "Nested Classes (including Inner Classes)". This second part continues with section 5.4 on "Array Examples", and ends with section 5.7 on "Serializing and Deserializing Collection with Objects of Arbitrary Types". Part 3 will continue with section 5.8 on "Built-in Serializers and Deserializers".
Link To This ArticleQR Code Link To This Articlehttp://goo.gl/qkceb

2011-06-25

Gson v Jackson - Part 1

tl;dnr

Use Jackson, not Gson. Use this article as a reference for basic features.

What is this post?

Is this yet another JSON-to/from-Java API comparison? Yes, it is. It's the most comprehensive comparison of using Gson versus Jackson for common JSON-to/from-Java tasks known. The sections below walk through each section of the Gson user guide, demonstrating similar implementations with Jackson. API features beyond what is described in the Gson user guide are then reviewed.
Link To This ArticleQR Code Link To This Articlehttp://goo.gl/YuYhx

2011-05-25

Deserialize JSON with Jackson into Polymorphic Types - A Complete Example

Jackson API Versions Note

The following code examples were written using Jackson 1.7.x or 1.8.x. They probably work as-is with Jackson 1.9.x, but Jackson 2.0 introduced API changes significant enough that this code does not compile with it. On initial review, it appears that package names changed, and at least one method signature changed or was moved or was renamed or no longer exists. In the near future, I may post updated code examples that use Jackson 2.x.

tl;dnr

Skip to the fourth, fifth, and sixth examples.

Why This Post Exists

While recently answering a question on StackOverflow.com about deserialization of JSON into polymorhpic types in Java, I couldn't find a simple and complete example using Jackson. At the time of this writing, the official documentation on the subject describes aspects of how to do this, but it doesn't have a full example. Searching other resources also didn't turn up any complete examples.
Link To This ArticleQR Code Link To This Articlehttp://goo.gl/nVKBZ

Following are deserialization examples with Jackson that build up to a complete example of populating a polymorphic data structure in Java. The first three examples do not involve Polymorphism. Polymorphism is introduced in the fourth example.

2010-11-12

HOWTO: Publish Javadoc on Google Code

Adding to Eric Burke's identically titled blog entry from three years ago, this entry details how to ensure Javadoc files have the correct svn:mime-type for normal browser viewing, when files are added to Subversion using the command line svn in M$ Windows.

For an example of viewing properly published Javadoc in a Google Code project, take a look at http://jgenere.googlecode.com/svn/tags/initial_port_v0.3r2010.1105/jgenere-initial_port/javadoc/index.html
Link To This ArticleQR Code Link To This Articlehttp://goo.gl/vM4jz

As described in the "Properties" section of Version Control with Subversion, Subversion includes subcommands to edit file properties, such as mime-type, with the command line tools. Also, the "Runtime Configuration Area" section, describes setting properties in the Windows registry, or in a "config" file. So, where is this mysterious config file?

The Secret Detail: The config file is in the %appdata%/Subversion directory and it's named simply "config", with no filename extension - at least it is on my computer. Notes: 1. On my system, %appdata% is the /Users/USERNAME/AppData/Roaming directory. 2. The %appdata%/Subversion directory wasn't created on my system after just installing svn tooling. (I'm using Slik SVN.) Instead, the directory was created after the first time I successfully executed a svn checkout command.

In the file named simply "config", just before the [auto-props] section, uncomment (by deleting any # characters in front of it) or add an entry for "enable-auto-props = yes", and then add the following three configurations to the [auto-props] section.
  • *.html = svn:mime-type=text/html
  • *.css = svn:mime-type=text/css
  • *.gif = svn:mime-type=image/gif
Of course, if the content to be published contains files with other extensions, add auto-props mime-type configurations for each of them, as well.

After editing and saving the config file, simply execute svn add and svn commit commands to add the Javadoc to the repository. If the docs were already in the repository before altering the config file, it will be necessary to make changes to them or delete and add them again, in order for the new mime-type properties to be set (or to use the subcommands for editing properties, as previously mentioned).