1717
1818package  org .openqa .selenium .bidi .module ;
1919
20- import  java .io .StringReader ;
2120import  java .util .Collections ;
2221import  java .util .HashSet ;
2322import  java .util .List ;
4342import  org .openqa .selenium .bidi .network .ProvideResponseParameters ;
4443import  org .openqa .selenium .bidi .network .ResponseDetails ;
4544import  org .openqa .selenium .internal .Require ;
46- import  org .openqa .selenium .json .Json ;
4745import  org .openqa .selenium .json .JsonInput ;
4846
4947public  class  Network  implements  AutoCloseable  {
5048
5149  private  final  Set <String > browsingContextIds ;
5250
53-   private  static  final  Json  JSON  = new  Json ();
54- 
5551  private  final  BiDi  bidi ;
5652
5753  private  final  Event <BeforeRequestSent > beforeRequestSentEvent  =
@@ -71,13 +67,18 @@ public class Network implements AutoCloseable {
7167
7268  private  final  Function <JsonInput , BytesValue > getDataResultMapper  =
7369      jsonInput  -> {
74-         Map <String , Object > result  = jsonInput .read (Map .class );
75-         Object  bytesObj  = result .get ("bytes" );
76- 
77-         try  (StringReader  reader  = new  StringReader (JSON .toJson (bytesObj ));
78-             JsonInput  bytesInput  = JSON .newInput (reader )) {
79-           return  BytesValue .fromJson (bytesInput );
70+         jsonInput .beginObject ();
71+         BytesValue  bytes  = null ;
72+         while  (jsonInput .hasNext ()) {
73+           String  name  = jsonInput .nextName ();
74+           if  ("bytes" .equals (name )) {
75+             bytes  = BytesValue .fromJson (jsonInput );
76+           } else  {
77+             jsonInput .skipValue ();
78+           }
8079        }
80+         jsonInput .endObject ();
81+         return  bytes ;
8182      };
8283
8384  public  Network (WebDriver  driver ) {
0 commit comments