Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid trailing spaces in manifestJsonEx output #191

Merged
merged 1 commit into from
May 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions stdlib/std.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -726,16 +726,16 @@ limitations under the License.
error "Tried to manifest function at " + path
else if std.type(v) == "array" then
local range = std.range(0, std.length(v) - 1);
local lines = ["[\n" + cindent]
+ std.join([",\n" + cindent],
[[indent + aux(v[i], path + [i], cindent + indent)] for i
local lines = ["[\n"]
+ std.join([",\n"],
[[cindent + indent + aux(v[i], path + [i], cindent + indent)] for i
in range])
+ ["\n" + cindent + "]"];
std.join("", lines)
else if std.type(v) == "object" then
local lines = ["{\n" + cindent]
+ std.join([",\n" + cindent],
[[indent + "\"" + k + "\": "
local lines = ["{\n"]
+ std.join([",\n"],
[[cindent + indent + "\"" + k + "\": "
+ aux(v[k], path + [k], cindent + indent)]
for k in std.objectFields(v)])
+ ["\n" + cindent + "}"];
Expand Down
8 changes: 8 additions & 0 deletions test_suite/stdlib.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,16 @@ std.assertEqual(std.splitLimit("/foo/", "/", 1), ["", "foo/"]) &&
std.assertEqual(std.manifestJsonEx({
x: [1, 2, 3, true, false, null, "string\nstring"],
y: { a: 1, b: 2, c: [1, 2] },
emptyArray: [],
emptyObject: {},
}, " ") + "\n", |||
{
"emptyArray": [

],
"emptyObject": {

},
"x": [
1,
2,
Expand Down