File tree Expand file tree Collapse file tree 3 files changed +30
-9
lines changed
src/EasyConfig.SiteExtension/Controllers Expand file tree Collapse file tree 3 files changed +30
-9
lines changed Original file line number Diff line number Diff line change 2323 "ASPNETCORE_ENVIRONMENT" : " Development" ,
2424 "EASYCONFIG__apiUrl" : " https://codez.one/api" ,
2525 "EASYCONFIG__test__value" : " blubb" ,
26+ "EASYCONFIG__peng__0" : " null" ,
27+ "EASYCONFIG__peng__1" : " eins" ,
2628 //"KeyVault__Uri": "peng"
2729 //"KeyVault__Uri__0": "peng",
2830 //"KeyVault__Uri__1": "puff"
Original file line number Diff line number Diff line change 11{
22 "sdk" : {
3- "version" : " 3.0.100 "
3+ "version" : " 3.0.101 "
44 }
55}
Original file line number Diff line number Diff line change 11namespace EasyConfig . SiteExtension . Controllers
22{
33 using System . Collections . Generic ;
4+ using System . Linq ;
45 using System . Text . Json ;
56 using Microsoft . AspNetCore . Mvc ;
67 using Microsoft . Extensions . Configuration ;
@@ -34,18 +35,36 @@ public JToken GetEnvironment()
3435
3536 private JToken Serialize ( IConfiguration config )
3637 {
37- var obj = new JObject ( ) ;
38- foreach ( var child in config . GetChildren ( ) )
39- {
40- obj . Add ( child . Key , this . Serialize ( child ) ) ;
41- }
38+ var childs = config . GetChildren ( ) ;
39+ var isArray = childs . Any ( ) && childs . All ( child => int . TryParse ( child . Key , out var number ) ) ;
4240
43- if ( ! obj . HasValues && config is IConfigurationSection section )
41+ if ( isArray )
4442 {
45- return new JValue ( section . Value ) ;
43+ var obj = new JArray ( ) ;
44+
45+ foreach ( var child in childs )
46+ {
47+ obj . Add ( this . Serialize ( child ) ) ;
48+ }
49+
50+ return obj ;
4651 }
52+ else
53+ {
54+ var obj = new JObject ( ) ;
55+
56+ foreach ( var child in childs )
57+ {
58+ obj . Add ( child . Key , this . Serialize ( child ) ) ;
59+ }
4760
48- return obj ;
61+ if ( ! obj . HasValues && config is IConfigurationSection section )
62+ {
63+ return new JValue ( section . Value ) ;
64+ }
65+
66+ return obj ;
67+ }
4968 }
5069 }
5170}
You can’t perform that action at this time.
0 commit comments