PDA

View Full Version : Using JSON to post fixed-formatted text



dlethe
5 Mar 2008, 11:06 PM
I need to display the results of some command-line programs in a TextArea, and need advice for best way to encode/decode the output so I can render it within a TextArea.

I have to insure that no whitespace is lost and the newlines are handled properly. I'm thinking a simple way may be to just encode the entire command-line output as a single JSON name/value object. I then make the entire command-line output a single JSON-encoded string that somehow encodes embedded quotes, newlines, carraige-returns. Any advice?

evant
5 Mar 2008, 11:13 PM
You can use:



var newline = '\n';
var ret = '\r';


Depending on the platform you're targetting.