Skip to content

Commit edccc19

Browse files
authored
Render list elements as non-root always (#832)
1 parent e1519d7 commit edccc19

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

config/src/main/java/com/typesafe/config/impl/SimpleConfigList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ protected void render(StringBuilder sb, int indent, boolean atRoot, ConfigRender
231231
}
232232
indent(sb, indent + 1, options);
233233

234-
v.render(sb, indent + 1, atRoot, options);
234+
v.render(sb, indent + 1, false, options);
235235
sb.append(",");
236236
if (options.getFormatted())
237237
sb.append('\n');

config/src/test/scala/com/typesafe/config/impl/ConfigValueTest.scala

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,4 +986,23 @@ class ConfigValueTest extends TestUtils {
986986
val rendered = config.root.render(ConfigRenderOptions.concise())
987987
assertEquals("""{"0":"a","1":"b","2":"c","3":"d","10":"e","20":"g","30":"h","999999999999999999999999999999999999999999999":0,"20a":"f"}""", rendered)
988988
}
989+
990+
@Test
991+
def renderList(): Unit = {
992+
val config = parseConfig("""root=[{foo=bar}, {baz=qux}]""")
993+
val rendered = config.getValue("root").render(ConfigRenderOptions.concise().setFormatted(true).setJson(false))
994+
assertEquals(
995+
"""[
996+
| {
997+
| foo=bar
998+
| },
999+
| {
1000+
| baz=qux
1001+
| }
1002+
|]"""
1003+
.stripMargin
1004+
.replaceAll("\r", ""), // Remove Windows line endings
1005+
rendered
1006+
)
1007+
}
9891008
}

0 commit comments

Comments
 (0)