Problem
When rendering an array, it renders always a trailing comma, which I'm assuming is not the intended functionality, but instead it should be rendering a comma just for all the elements prior to the last
|
impl JsonRender for Json { |
|
fn render(&self) -> String { |
|
match *self { |
|
Json::String(ref s) => s.to_string(), |
|
Json::Bool(i) => i.to_string(), |
|
Json::Number(ref n) => n.to_string(), |
|
Json::Null => "".to_owned(), |
|
Json::Array(ref a) => { |
|
let mut buf = String::new(); |
|
buf.push('['); |
|
for i in a.iter() { |
|
buf.push_str(i.render().as_ref()); |
|
buf.push_str(", "); |
|
} |
|
buf.push(']'); |
|
buf |
|
} |
|
Json::Object(_) => "[object]".to_owned(), |
|
} |
|
} |
|
} |
Example
We want to render the following array: [1, 2, 3]
Expected Result
It gets rendered as [1, 2, 3]
Actual Result
It gets rendered as [1, 2, 3, ]
Problem
When rendering an array, it renders always a trailing comma, which I'm assuming is not the intended functionality, but instead it should be rendering a comma just for all the elements prior to the last
handlebars-rust/src/json/value.rs
Lines 110 to 130 in 23ca8d7
Example
We want to render the following array: [1, 2, 3]
Expected Result
It gets rendered as
[1, 2, 3]Actual Result
It gets rendered as
[1, 2, 3, ]