owensd/json-swift

Unpretty stringify?

paulyoung opened this issue · 7 comments

In JavaScript I can do this to receive a string with no spaces:

JSON.stringify(json, null, 0);

I've tried this but it didn't work as I expected:

json.stringify(indent: "")

It's also weird that I can supply any string for indent.

+1 for a numerical param there instead.

JSON.stringify() in JavaScript accepts both a string and a numeric value; I can look into supporting the numeric value as well.

What happened for intent: ""?

Using indent: """ I get the following, vs the expected:

<{"command" : "topic","payload" : {"key" : "value"},"protocol" : "channel"}>
<{"command":"topic","payload":{"key":"value"},"protocol":"channel"}>

Seems like the hard coded spaces here and here should be replaced by indent.

<{"command" : "topic","payload" : {"key" : "value"},"protocol" : "channel"}> doesn't seem like the right behavior. I can follow what JSON.stringify() does though.

Should be fixed now.

👍