@@ -132,8 +132,10 @@ public T GetItem<T>(string key)
132132 // This might be a bad idea especially if the file is in use, as this can take a long time
133133 _jsonData = GetJsonObjectFromFile ( ) ;
134134 }
135+
136+ var convertedKey = _convertPathToCorrectCamelCase ( key ) ;
135137
136- var token = _jsonData [ key ] ;
138+ var token = _jsonData [ convertedKey ] ;
137139
138140 if ( token == null )
139141 {
@@ -156,7 +158,9 @@ public dynamic GetItem(string key)
156158 _jsonData = GetJsonObjectFromFile ( ) ;
157159 }
158160
159- var token = _jsonData [ key ] ;
161+ var convertedKey = _convertPathToCorrectCamelCase ( key ) ;
162+
163+ var token = _jsonData [ convertedKey ] ;
160164
161165 if ( token == null )
162166 return null ;
@@ -170,12 +174,14 @@ public dynamic GetItem(string key)
170174
171175 private Task < bool > Insert < T > ( string key , T item , bool isAsync = false )
172176 {
177+ var convertedKey = _convertPathToCorrectCamelCase ( key ) ;
178+
173179 ( bool , JObject ) UpdateAction ( )
174180 {
175- if ( _jsonData [ key ] != null )
181+ if ( _jsonData [ convertedKey ] != null )
176182 return ( false , _jsonData ) ;
177183
178- _jsonData [ key ] = JToken . FromObject ( item ) ;
184+ _jsonData [ convertedKey ] = JToken . FromObject ( item ) ;
179185 return ( true , _jsonData ) ;
180186 }
181187
@@ -188,12 +194,14 @@ private Task<bool> Insert<T>(string key, T item, bool isAsync = false)
188194
189195 private Task < bool > Replace < T > ( string key , T item , bool upsert = false , bool isAsync = false )
190196 {
197+ var convertedKey = _convertPathToCorrectCamelCase ( key ) ;
198+
191199 ( bool , JObject ) UpdateAction ( )
192200 {
193- if ( _jsonData [ key ] == null && upsert == false )
201+ if ( _jsonData [ convertedKey ] == null && upsert == false )
194202 return ( false , _jsonData ) ;
195203
196- _jsonData [ key ] = JToken . FromObject ( item ) ;
204+ _jsonData [ convertedKey ] = JToken . FromObject ( item ) ;
197205 return ( true , _jsonData ) ;
198206 }
199207
@@ -206,21 +214,23 @@ private Task<bool> Replace<T>(string key, T item, bool upsert = false, bool isAs
206214
207215 private Task < bool > Update ( string key , dynamic item , bool isAsync = false )
208216 {
217+ var convertedKey = _convertPathToCorrectCamelCase ( key ) ;
218+
209219 ( bool , JObject ) UpdateAction ( )
210220 {
211- if ( _jsonData [ key ] == null )
221+ if ( _jsonData [ convertedKey ] == null )
212222 return ( false , _jsonData ) ;
213223
214- var toUpdate = SingleDynamicItemReadConverter ( _jsonData [ key ] ) ;
224+ var toUpdate = SingleDynamicItemReadConverter ( _jsonData [ convertedKey ] ) ;
215225
216226 if ( ObjectExtensions . IsReferenceType ( item ) && ObjectExtensions . IsReferenceType ( toUpdate ) )
217227 {
218228 ObjectExtensions . CopyProperties ( item , toUpdate ) ;
219- _jsonData [ key ] = JToken . FromObject ( toUpdate ) ;
229+ _jsonData [ convertedKey ] = JToken . FromObject ( toUpdate ) ;
220230 }
221231 else
222232 {
223- _jsonData [ key ] = JToken . FromObject ( item ) ;
233+ _jsonData [ convertedKey ] = JToken . FromObject ( item ) ;
224234 }
225235
226236 return ( true , _jsonData ) ;
@@ -235,9 +245,11 @@ private Task<bool> Update(string key, dynamic item, bool isAsync = false)
235245
236246 private Task < bool > Delete ( string key , bool isAsync = false )
237247 {
248+ var convertedKey = _convertPathToCorrectCamelCase ( key ) ;
249+
238250 ( bool , JObject ) UpdateAction ( )
239251 {
240- var result = _jsonData . Remove ( key ) ;
252+ var result = _jsonData . Remove ( convertedKey ) ;
241253 return ( result , _jsonData ) ;
242254 }
243255
0 commit comments