Commit 36d84649 authored by Emeric Verschuur's avatar Emeric Verschuur

BSON serializer fix

parent 5bfb4ed5
......@@ -796,7 +796,7 @@ public abstract class Variant implements Comparable<Object> {
}
byte[] payloadBytes = payload.toByteArray();
ByteArrayOutputStream ret = new ByteArrayOutputStream();
write32(ret, payloadBytes.length + 1);
write32(ret, payloadBytes.length + 5);
ret.write(payloadBytes);
ret.write(BSON_TOKEN_END);
return ret.toByteArray();
......
......@@ -83,7 +83,7 @@ public class VariantUInt extends VariantNumber {
@Override
public long longValue() {
return data;
return data & 0xFFFFFFFFL;
}
@Override
......
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import org.mbedsys.jvar.Variant;
......@@ -7,9 +8,11 @@ import org.mbedsys.jvar.Variant;
public class Test {
public static void main(String[] args) {
try {
// Variant value = Variant.newParser(new FileInputStream("rs/test.json"), Variant.Format.JSON).next();
Variant value = Variant.newParser(new FileInputStream("rs/test.bson"), Variant.Format.BSON).next();
Variant value = Variant.newParser(new FileInputStream("rs/test.json"), Variant.Format.JSON).next();
// Variant value = Variant.newParser(new FileInputStream("rs/test.bson"), Variant.Format.BSON).next();
// Variant value = Variant.newParser(new FileInputStream("rs/test.bcon"), Variant.Format.BCON).next();
Variant.serializeBCON(new FileOutputStream("rs/test_out.bcon"), value);
Variant.serializeBSON(new FileOutputStream("rs/test_out.bson"), value);
System.out.println(value);
} catch (IOException e) {
e.printStackTrace();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment