Skip to content

Commit

Permalink
escape tabs in string output
Browse files Browse the repository at this point in the history
  • Loading branch information
brianm committed Feb 5, 2017
1 parent a144969 commit 6503367
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions sample.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "Brian",
"pets":["dog"],
"story":"Sometimes\nI add newlines and\ttabs\n",
"diet":{
"drink": "coffee",
"eat": "bacon"
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ fn render(v: &Value) -> String {
&Value::Null => String::new(),
&Value::Bool(ref b) => format!("{}", b),
&Value::Number(ref b) => format!("{}", b),
&Value::String(ref s) => format!("{}", s.replace("\n", "\\n")),
&Value::String(ref s) => format!("{}", s.replace("\n", "\\n")
.replace("\t", "\\t")),
&Value::Array(_) => format!("{}", v),
&Value::Object(_) => format!("{}", v),
}
Expand Down

0 comments on commit 6503367

Please sign in to comment.