nlight-jdev / jcouchdb

Automatically exported from code.google.com/p/jcouchdb
Other
0 stars 0 forks source link

org.svenson.JSONParseException: Cannot set property results on class org.jcouchdb.document.ChangeNotification #85

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. If you try to parse any json string with Svenson Json parser with this call 
ChangeNotification changeNotification = JSONParser.
                            defaultJSONParser().parse(ChangeNotification.class, jso
I get the exception and cannot parse the json object.

What is the expected output? What do you see instead?
Expected out put is to have ChangeNotification object created after parsing 
json string with this call.

ChangeNotification changeNotification = JSONParser.
                            defaultJSONParser().parse(ChangeNotification.class, json);

The out put I am getting is exception 

org.svenson.JSONParseException: Cannot set property results on class 
org.jcouchdb.document.ChangeNotification
    at org.svenson.JSONParser.parseObjectInto(JSONParser.java:589)
    at org.svenson.JSONParser.parse(JSONParser.java:391)
    at org.svenson.JSONParser.parse(JSONParser.java:336)
    at com.soundsgood.polling.CouchDBContinousPoller.run(CouchDBContinousPoller.java:98)
    at java.lang.Thread.run(Thread.java:680)

What version of the product are you using? On what operating system?
I am using couchdb 1.2 with Jcouchdb 1.0.1-1 and svenson 1.4  on Mac OSX Lion

Please provide any additional information below.

Original issue reported on code.google.com by jiten.g...@gmail.com on 26 Aug 2012 at 5:21

GoogleCodeExporter commented 8 years ago
Example Json object that I am parsing is:

 {"results":[
{"seq":14,"id":"c5545c7896b619091628ad1f1c0048c1","changes":[{"rev":"14-7d63aecc
8816bfc0e4064825ffeb8cb9"}]},
{"seq":16,"id":"c5545c7896b619091628ad1f1c004f38","changes":[{"rev":"2-7051cbe5c
8faecd085a3fa619e6e6337"}]}
],
"last_seq":16}

Original comment by jiten.g...@gmail.com on 26 Aug 2012 at 5:37

GoogleCodeExporter commented 8 years ago
Nevermind I figured out it seems the call expects the json to be of the form 

{"seq":14,"id":"c5545c7896b619091628ad1f1c0048c1","changes":[{"rev":"14-7d63aecc
8816bfc0e4064825ffeb8cb9"}]}

When I pass this  to the call 
ChangeNotification changeNotification = JSONParser. 
defaultJSONParser().parse(ChangeNotification.class, json);
it worked.

Original comment by jiten.g...@gmail.com on 26 Aug 2012 at 6:01

GoogleCodeExporter commented 8 years ago
Yes ... Each of the items in the results array is a ChangeNotification 
document.  I'm glad you figured out the problem but I thought I'd also warn you 
that there are changes to some of the document formats in CouchDB 1.1 and 1.2 
that aren't included in jcouchdb yet.  Some are incorporated in the 1.1.0-1 
branch but some are outstanding.

Original comment by smoye...@gmail.com on 1 Dec 2012 at 12:53