desc: Tests RQL json parsing tests: - cd: r.json("[1,2,3]") ot: [1,2,3] - cd: r.json("1") ot: 1 - cd: r.json("{}") ot: {} - cd: r.json('"foo"') ot: "foo" - cd: r.json("[1,2") ot: err("ReqlQueryLogicError", 'Failed to parse "[1,2" as JSON:' + ' Missing a comma or \']\' after an array element.', [0]) - cd: r.json("[1,2,3]").to_json_string() ot: '[1,2,3]' - js: r.json("[1,2,3]").toJSON() py: r.json("[1,2,3]").to_json() ot: '[1,2,3]' - cd: r.json("{\"foo\":4}").to_json_string() ot: '{"foo":4}' - js: r.json("{\"foo\":4}").toJSON() py: r.json("{\"foo\":4}").to_json() ot: '{"foo":4}' # stress test: data is from http://www.mockaroo.com/ - def: text = '[{"id":1,"first_name":"Harry","last_name":"Riley","email":"hriley0@usgs.gov","country":"Andorra","ip_address":"221.25.65.136"},{"id":2,"first_name":"Bonnie","last_name":"Anderson","email":"banderson1@list-manage.com","country":"Tuvalu","ip_address":"116.162.43.150"},{"id":3,"first_name":"Marie","last_name":"Schmidt","email":"mschmidt2@diigo.com","country":"Iraq","ip_address":"181.105.59.57"},{"id":4,"first_name":"Phillip","last_name":"Willis","email":"pwillis3@com.com","country":"Montenegro","ip_address":"24.223.139.156"}]' - def: sorted = '[{"country":"Andorra","email":"hriley0@usgs.gov","first_name":"Harry","id":1,"ip_address":"221.25.65.136","last_name":"Riley"},{"country":"Tuvalu","email":"banderson1@list-manage.com","first_name":"Bonnie","id":2,"ip_address":"116.162.43.150","last_name":"Anderson"},{"country":"Iraq","email":"mschmidt2@diigo.com","first_name":"Marie","id":3,"ip_address":"181.105.59.57","last_name":"Schmidt"},{"country":"Montenegro","email":"pwillis3@com.com","first_name":"Phillip","id":4,"ip_address":"24.223.139.156","last_name":"Willis"}]' - cd: r.json(text).to_json_string() ot: sorted - cd: r.expr(r.minval).to_json_string() ot: err('ReqlQueryLogicError', 'Cannot convert `r.minval` to JSON.') - cd: r.expr(r.maxval).to_json_string() ot: err('ReqlQueryLogicError', 'Cannot convert `r.maxval` to JSON.') - cd: r.expr(r.minval).coerce_to('string') ot: err('ReqlQueryLogicError', 'Cannot convert `r.minval` to JSON.') - cd: r.expr(r.maxval).coerce_to('string') ot: err('ReqlQueryLogicError', 'Cannot convert `r.maxval` to JSON.') - cd: r.time(2014,9,11, 'Z') runopts: time_format: 'raw' ot: {'timezone':'+00:00','$reql_type$':'TIME','epoch_time':1410393600} - cd: r.time(2014,9,11, 'Z').to_json_string() ot: '{"$reql_type$":"TIME","epoch_time":1410393600,"timezone":"+00:00"}' - cd: r.point(0,0) ot: {'$reql_type$':'GEOMETRY','coordinates':[0,0],'type':'Point'} - cd: r.point(0,0).to_json_string() ot: '{"$reql_type$":"GEOMETRY","coordinates":[0,0],"type":"Point"}' - def: rb: s = "\x66\x6f\x6f".force_encoding('BINARY') py: s = b'\x66\x6f\x6f' js: s = Buffer("\x66\x6f\x6f", 'binary') - cd: r.binary(s) ot: s - cd: r.expr("foo").coerce_to("binary").to_json_string() ot: '{"$reql_type$":"BINARY","data":"Zm9v"}'