简体   繁体   中英

Can I get data as JSON string when I am listening updates from RethinkDB?

Cursor changeCursor = r.table(Hardcoded.rethinkDBTableName()).changes().getField("new_val").without("id").run(conn);
    for (Object change : changeCursor) {
        System.out.println(change);
    }

RESULT:

{  
   askPrice=1.29846,
   symbol=EUR/USD,
   bidTime=1455800529000,
   askTime=1455800529000,
   bidSize=1,
   askSize=1,
   bidPrice=1.2984
}

EXPECTED:

{  
   "askSize":1,
   "askPrice":1.2978,
   "askTime":1455729430000,
   "bidTime":1455729430000,
   "bidPrice":1.29778,
   "symbol":"EUR/USD",
   "bidSize":1
}

您可以编写r.table(Hardcoded.rethinkDBTableName()).changes().getField("new_val").without("id").map(val -> val.toJson()) ,我认为这样做会做些什么你要。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM