title: Pandas read_json() encoding = 'utf-8-sig' option is not working for BytesIO object (file-like object)
body: <p>When trying to load a <a href="https://jsonlines.org/" rel="nofollow noreferrer">jsonlines</a> file encoded in UTF8-BOM as Bytes data directly into pandas dataframe, getting error 'ValueError' object has no attribute 'message' (this generic error happens when encoding is different). I am trying to read data from Azure Datalake Gen-2 using azure.storage.filedatalake.DataLakeFileClient and it gives me bytes data and i am trying to load that data into pandas dataframe directly.The code snippet failing is given below</p>
  <pre><code>from azure.identity import ClientSecretCredential
  from azure.storage.filedatalake import DataLakeServiceClient
  from io import BytesIO,StringIO 
  
  
  
  def initialize_storage_account_ad(storage_account_name, client_id, client_secret, tenant_id):
      
      try:  
          global service_client
  
          credential = ClientSecretCredential(tenant_id, client_id, client_secret)
  
          service_client = DataLakeServiceClient(account_url=&quot;{}://{}.dfs.core.windows.net&quot;.format(
              &quot;https&quot;, storage_account_name), credential=credential)
      
      except Exception as e:
          print(e.message)
  
  initialize_storage_account_ad(storage_account_name, client_id, client_secret, tenant_id)
  data_folder = '/raw/data/'
  
  file_system_client = service_client.get_file_system_client(file_system=&quot;dls&quot;)
  paths = file_system_client.get_paths(path=data_folder)
  
  directory_client = file_system_client.get_directory_client(data_folder)
  
  file_client = directory_client.get_file_client('API_COUNTRY.json')
  download = file_client.download_file()
  
  downloaded_bytes = download.readall()
  df = pd.read_json(BytesIO(downloaded_bytes),lines = True,encoding = 'utf-8-sig')
  display(df) 
  </code></pre>
  <p>The same code works if i try with UTF-8 encoding, also if i write UTF8-BOM jsonlines to a file and load it using <code>df = pd.read_json('country.json',lines = True,encoding = 'utf-8-sig')</code> then also it works. Any help is greatly appreciated.</p>
  <p>Error StackTrace</p>
  <pre><code>ValueError                                Traceback (most recent call last)
  &lt;ipython-input-13-b150d9150c5a&gt; in &lt;module&gt;
       31 
       32 downloaded_bytes = download.readall()
  ---&gt; 33 df = pd.read_json(BytesIO(downloaded_bytes),lines = True,encoding = 'utf-8-sig')
       34 display(df)
  
  C:\Program Files\Python36\lib\site-packages\pandas\util\_decorators.py in wrapper(*args, **kwargs)
      197                 else:
      198                     kwargs[new_arg_name] = new_arg_value
  --&gt; 199             return func(*args, **kwargs)
      200 
      201         return cast(F, wrapper)
  
  C:\Program Files\Python36\lib\site-packages\pandas\util\_decorators.py in wrapper(*args, **kwargs)
      294                 )
      295                 warnings.warn(msg, FutureWarning, stacklevel=stacklevel)
  --&gt; 296             return func(*args, **kwargs)
      297 
      298         return wrapper
  
  C:\Program Files\Python36\lib\site-packages\pandas\io\json\_json.py in read_json(path_or_buf, orient, typ, dtype, convert_axes, convert_dates, keep_default_dates, numpy, precise_float, date_unit, encoding, lines, chunksize, compression, nrows)
      616         return json_reader
      617 
  --&gt; 618     result = json_reader.read()
      619     if should_close:
      620         filepath_or_buffer.close()
  
  C:\Program Files\Python36\lib\site-packages\pandas\io\json\_json.py in read(self)
      751                 data = ensure_str(self.data)
      752                 data = data.split(&quot;\n&quot;)
  --&gt; 753                 obj = self._get_object_parser(self._combine_lines(data))
      754         else:
      755             obj = self._get_object_parser(self.data)
  
  C:\Program Files\Python36\lib\site-packages\pandas\io\json\_json.py in _get_object_parser(self, json)
      775         obj = None
      776         if typ == &quot;frame&quot;:
  --&gt; 777             obj = FrameParser(json, **kwargs).parse()
      778 
      779         if typ == &quot;series&quot; or obj is None:
  
  C:\Program Files\Python36\lib\site-packages\pandas\io\json\_json.py in parse(self)
      884 
      885         else:
  --&gt; 886             self._parse_no_numpy()
      887 
      888         if self.obj is None:
  
  C:\Program Files\Python36\lib\site-packages\pandas\io\json\_json.py in _parse_no_numpy(self)
     1117         if orient == &quot;columns&quot;:
     1118             self.obj = DataFrame(
  -&gt; 1119                 loads(json, precise_float=self.precise_float), dtype=None
     1120             )
     1121         elif orient == &quot;split&quot;:
  
  ValueError: Expected object or value
  
  </code></pre>
  <p>Beginning of the bytes values:</p>
  <pre><code>('b', ['0xef', '0xbb', '0xbf', '0x7b', '0x22', '0x49', '0x44', '0x45', '0x4e', '0x54', '0x49', '0x46', '0x49', '0x45', '0x52', '0x22', '0x3a', '0x22', '0x41', '0x66', '0x67', '0x68', '0x61', '0x6e', '0x69', '0x73', '0x74', '0x61', '0x6e', '0x22', '0x2c', '0x22', '0x49', '0x44', '0x45', '0x4e', '0x54', '0x49', '0x46', '0x49', '0x45', '0x52', '0x5f', '0x49', '0x53', '0x4f', '0x32', '0x22', '0x3a', '0x22', '0x41', '0x46', '0x22', '0x2c', '0x22', '0x49', '0x44', '0x45', '0x4e', '0x54', '0x49', '0x46', '0x49', '0x45', '0x52', '0x5f', '0x49', '0x53', '0x4f', '0x33', '0x22', '0x3a', '0x22', '0x41', '0x46', '0x47', '0x22', '0x2c', '0x22', '0x49', '0x44', '0x45', '0x4e', '0x54', '0x49', '0x46', '0x49', '0x45', '0x52', '0x5f', '0x49', '0x53', '0x4f', '0x5f', '0x4e', '0x55', '0x4d', '0x45', '0x52', '0x49', '0x43', '0x22', '0x3a', '0x22', '0x30', '0x30', '0x34', '0x22', '0x2c', '0x22', '0x4f', '0x46', '0x46', '0x49', '0x43', '0x49', '0x41', '0x4c', '0x5f', '0x53', '0x48', '0x4f', '0x52', '0x54', '0x5f', '0x49', '0x44', '0x45'])
  
  </code></pre>