reqlite icon indicating copy to clipboard operation
reqlite copied to clipboard

Implement a matching JSON.stringify

Open neumino opened this issue 10 years ago • 7 comments
trafficstars

Errors sent back by RethinkDB can contain a JSON value. JSON.stringify(..., null, 4) doesn't quite match their syntax. Their typically use tabs instead of spaces.

If we have a matching JSON.stringify method, we can simplify some tests (those the error on a colon).

neumino avatar May 21 '15 01:05 neumino

Is that something we could potentially "borrow" from their codebase?

zephraph avatar May 21 '15 01:05 zephraph

Well, it's not something in the driver, their server send the JSON strings, so I guess cJSON (or whatever they replaced it with) output this JSON strings with tab. So we can't just copy paste code.

Their license is also not compatible with MIT I think - though I don't know how these thing really work...

neumino avatar May 21 '15 02:05 neumino

Ah, well that's unfortunate.

zephraph avatar May 21 '15 02:05 zephraph

Can you paste some example error objects in here and how they are being stringified? Or give instructions on how to reproduce? I could maybe take a look at this.

ccheever avatar May 22 '15 07:05 ccheever

If you remove the lines like these in the tests: https://github.com/neumino/reqlite/blob/a09e61f96d23e62d2ef12efd25ef995caccbdf4e/test/selecting-data.js#L161

You will see failures and the output of JSON.stringify to reproduce

neumino avatar May 22 '15 14:05 neumino

@neumino if you just need to use tabs instead of spaces, JSON.stringify(..., null, '\t') should work.

marshall007 avatar Jun 24 '15 14:06 marshall007

Thanks @marshall007. There are a few more things that a different. There are a few or missing new lines sometimes too (typically from what I remember RethinkDB doens't add a new line in an array.

neumino avatar Jun 24 '15 14:06 neumino