Open GoogleCodeExporter opened 9 years ago
Shouldn't you be using JsonIOUtil.mergeFrom instead of JsonIOUtil.parseListFrom?
Can you post the fully qualified class name of the timestamp class?
If you can post a simple example that would be great.
Original comment by david.yu...@gmail.com
on 21 May 2012 at 11:49
Hi,
thank you for your reply. I think the issue is when serializing because when i
see the generated file the logDate is as described above.
The object I use is fairly simple:
package com.test;
import java.io.Serializable;
import java.sql.Timestamp;
public class MyLog {
private static final long serialVersionUID = 3802847070993248978L;
private Timestamp logDate;
private String msgTxt;
private String timezone;
public MyLog() {
}
public Timestamp getLogDate() {
return logDate;
}
public void setLogDate(Timestamp theLogDate) {
logDate = theLogDate;
}
public String getMsgTxt() {
return msgTxt;
}
public void setMsgTxt(String theMsgTxt) {
msgTxt = theMsgTxt;
}
public String getTimezone() {
return timezone;
}
public void setTimezone(String theTimezone) {
timezone = theTimezone;
}
}
Original comment by thomas.b...@gmail.com
on 21 May 2012 at 12:00
The problem was that you are using JsonIOUtil.parseListFrom, when you should've
been using JsonIOUtil.mergeFrom.
Also, there are no built-in serializers for java.sql.Timestamp (its a scalar
value none-the-less).
I've attached a sample which basically solves your problem (using 1.0.7
delegate)
Original comment by david.yu...@gmail.com
on 21 May 2012 at 12:20
Attachments:
Thank you for your reply,
I tried your solution and worked fine :)
I was using parseListFrom because it gives me back the object list instead of
having a for (each line) loop. with mergeFrom. Or there is an alternative way
of using it to do something like:
objectList = JsonIOUtil.parseListFrom(in, schema, true, buffer);
JsonIOUtil.mergeFrom(in, objectList, schema, true, buffer);
but i do not serialize list i serialize my MyLog object and append it to the
file one by one.
Thank you again you are helping me a lot :)
Original comment by thomas.b...@gmail.com
on 21 May 2012 at 1:32
If you want to make use of protostuff pipes (transcoding), then you'll want to
do:
class Wrapper
{
List<MyLog> logs;
}
And use JsonIOUtil.writeTo and JsonIOUtil.mergeFrom.
If not then:
// serialize
List<MyLog> logs = getLogs();
JsonIOUtil.writeListTo(out, logs, schema, false, buffer);
// produces:
// [{"logDate":1337609415306,"msgTxt":"1","timezone":"Europe/Moscow"}]
// deserialize
List<MyLog> parsedLogs = JsonIOUtil.parseListFrom(in, schema, false, buffer);
Original comment by david.yu...@gmail.com
on 21 May 2012 at 2:12
Original issue reported on code.google.com by
thomas.b...@gmail.com
on 21 May 2012 at 9:00