File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -167,6 +167,28 @@ async fn game_count_get(
167167 Ok ( text) => match serde_json:: from_str ( & text) {
168168 Ok ( text_json) => {
169169 let text_json: serde_json:: Value = text_json;
170+
171+ let mut json_is_ok = false ;
172+ match text_json. as_object ( ) {
173+ Some ( obj_json) => {
174+ if obj_json. contains_key ( "response" ) {
175+ match obj_json[ "response" ] . as_object ( ) {
176+ Some ( obj_response_json) => {
177+ if obj_response_json. contains_key ( "player_count" ) {
178+ json_is_ok = true ;
179+ }
180+ }
181+ None => ( ) ,
182+ }
183+ }
184+ }
185+ None => ( ) ,
186+ }
187+ if !json_is_ok {
188+ eprintln ! ( "ERROR: Malformed JSON response" ) ;
189+ return Ok ( ( ) ) ;
190+ }
191+
170192 let count = text_json[ "response" ] [ "player_count" ]
171193 . to_string ( )
172194 . parse :: < u32 > ( )
You can’t perform that action at this time.
0 commit comments