While testing @kokejb‘s preview patch this week I came across an issue when parsing the blog options JSON that we are using in the app. After a bit of debugging, I think that the org.JSON library isn’t going to cut the mustard for our JSON needs. It doesn’t appear to be able to correctly parse objects within other objects. Using JSONObject.toString() for the map returned in the wp.getOptions call returns what should be an object as a string:

{"software_version":"{value=3.6-alpha-23334, readonly=true, desc=Software Version}","blog_public":"{value=1, readonly=true, desc=Privacy access}","post_thumbnail":"{value=true, readonly=true, desc=Post Thumbnail}"}

I discovered Gson this week which gives you the expected results:

{"software_version":{"value":"3.6-alpha-23334","readonly":true,"desc":"Software Version"},"post_thumbnail":{"value":true,"readonly":true,"desc":"Post Thumbnail"},"blog_public":{"value":"1","readonly":true,"desc":"Privacy access"}}

I think I will add the Gson library since it fixes the issue and will set us up for better JSON support in case we start using the Jetpack REST API in the app more in the future.