code: def test_to_json_compression(
      compression_only,
      read_infer,
      to_infer,
      compression_to_extension,
      infer_string,
  ):
      with pd.option_context("future.infer_string", infer_string):
          # see gh-15008
          compression = compression_only
  
          # We'll complete file extension subsequently.
          filename = "test."
          filename += compression_to_extension[compression]
  
          df = pd.DataFrame({"A": [1]})
  
          to_compression = "infer" if to_infer else compression
          read_compression = "infer" if read_infer else compression
  
          with tm.ensure_clean(filename) as path:
              df.to_json(path, compression=to_compression)
              result = pd.read_json(path, compression=read_compression)
              tm.assert_frame_equal(result, df)
  
file_path: pandas/pandas/tests/io/json/test_compression.py
imports: from io import BytesIO, StringIO
  import pytest
  import pandas.util._test_decorators
  import pandas
  import pandas._testing
label_desc: Use image node_id 8 for calling a global function with example usage: test_to_json_compression(compression_only, read_infer, to_infer, compression_to_extension, infer_string) without return types