Java talking to iOS: Java objects to Apple plist serialization

I am happy to announce my first open source project java-plist-serializer that can help you with integrating Java and especially Spring based applications with iOS applications.  
I am working on project that has Java webapp as a backend and clients are iOS devices. Recently I’ve received task to create Web Service that returns plistProperty List data format used in iOS – as a response. Why plist and not JSON or classic XML? If you have to develop for iOS < 5.0 – there are no native classes to deserialize JSON. Property List format is supported by core iOS libraries so deserialization to NSDictionary is super fast and efficient.
There are few plist – related libraries for Java but each of them requires to do a lot of manual work and rewrite Java objects step by step into Java equivalents of Apple NS* classes. I think nobody likes this kind of task. Thats why I have developed library for serializing Java objects into Plist in similar way to XStream XML serialization.  


java-plist-serializer is an open source project hosted on Github that helps to develop communication between Java application and iOS application.


The heart of library is PlistSerializerImpl. In order to serialize obejcts to plist you have to create instance of PlistSerializerImpl and call one of serialization methods. For example:

Input classes:

public class Post {
    private String title;
    private Integer views = 0;
    private List<Comment> comments = new ArrayList<Comment>();
    private Author author;

    public Post(Author author, String title, Integer views) {
        this.title = title;
        this.views = views; = author;

public class Comment {
    private String content;
    private String author;

    public Comment(String author, String content) {
        this.content = content; = author;

public class Author {
    private String name;

Objects of those classes are created and plistSerializer.toXmlPlist method is called

Post post = new Post(new Author("jason bourne"), "java-plist-serializer introduction", 9);
post.addComment(new Comment("maciejwalkowiak", "first comment"));
post.addComment(new Comment("john doe", "second comment"));

PlistSerializerImpl plistSerializer = new PlistSerializerImpl();
String xml = plistSerializer.toXmlPlist(post);

xml variable will contain:

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
<plist version="1.0">
            <string>jason bourne</string>
                <string>first comment</string>
                <string>john doe</string>
                <string>second comment</string>
        <string>java-plist-serializer introduction</string>

Spring Framework Integration

In order to return plist as a response of Spring MVC controller you can use PlistView that extends AbstractView.

There are several ways to configure Spring MVC. The easiest to understand example of usage of PlistView:

public class BlogController {
    @RequestMapping(value = "/loadBlogPost", method = RequestMethod.GET)
    public ModelAndView loadBlogPost() {
        Post post = new Post(new Author("jason bourne"), "java-plist-serializer introduction", 9);
        post.addComment(new Comment("maciejwalkowiak", "first comment"));
        post.addComment(new Comment("john doe", "second comment"));

        ModelMap model = new ModelMap();
        model.addAttribute("RESULT", notification);

        return new ModelAndView(new PlistView(), model);

More detailed documentation can be found on project’s github page


Feel free to fork, extend. If you will find any issue please report them on github.

Reference: Java talking to iOS: Java objects to Apple plist serialization from our JCG partner Maciej Walkowiak at the Software Development Journey blog.

Related Whitepaper:

Functional Programming in Java: Harnessing the Power of Java 8 Lambda Expressions

Get ready to program in a whole new way!

Functional Programming in Java will help you quickly get on top of the new, essential Java 8 language features and the functional style that will change and improve your code. This short, targeted book will help you make the paradigm shift from the old imperative way to a less error-prone, more elegant, and concise coding style that’s also a breeze to parallelize. You’ll explore the syntax and semantics of lambda expressions, method and constructor references, and functional interfaces. You’ll design and write applications better using the new standards in Java 8 and the JDK.

Get it Now!  

One Response to "Java talking to iOS: Java objects to Apple plist serialization"

Leave a Reply

− four = 3

Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.

Sign up for our Newsletter

20,709 insiders are already enjoying weekly updates and complimentary whitepapers! Join them now to gain exclusive access to the latest news in the Java world, as well as insights about Android, Scala, Groovy and other related technologies.

As an extra bonus, by joining you will get our brand new e-books, published by Java Code Geeks and their JCG partners for your reading pleasure! Enter your info and stay on top of things,

  • Fresh trends
  • Cases and examples
  • Research and insights
  • Two complimentary e-books