Skip to content

Commit c7585f4

Browse files
Merge pull request #67 from aspnet/59-Json_Throws_Exception_Sectional_When_Not_Exist_In_Json_File
Use .TryGetValue() when we expect the key might not exist.
2 parents caeabc3 + 3520f0d commit c7585f4

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/Json/SimpleJsonConfigBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ private Dictionary<string, string> GetCurrentDictionary()
142142
{
143143
if (JsonMode == SimpleJsonConfigBuilderMode.Sectional && _currentSection != null)
144144
{
145-
Dictionary<string, string> d = _allSettings[_currentSection];
146-
return d ?? _allSettings[""];
145+
if (_allSettings.TryGetValue(_currentSection, out Dictionary<string, string> d))
146+
return d;
147147
}
148148

149149
return _allSettings[""];

0 commit comments

Comments
 (0)