code: def test_json_roundtrip(ray_start_regular_shared, fs, data_path):
      # Single block.
      df = pd.DataFrame({"one": [1, 2, 3], "two": ["a", "b", "c"]})
      ds = ray.data.from_pandas([df])
      ds._set_uuid("data")
      ds.write_json(data_path, filesystem=fs)
      file_path = os.path.join(data_path, "data_000000_000000.json")
      ds2 = ray.data.read_json([file_path], filesystem=fs)
      ds2df = ds2.to_pandas()
      assert ds2df.equals(df)
      # Test metadata ops.
      for block, meta in ds2._plan.execute().get_blocks_with_metadata():
          BlockAccessor.for_block(
              ray.get(block)
          ).size_bytes() == meta.size_bytes
  
      if fs is None:
          os.remove(file_path)
      else:
          fs.delete_file(_unwrap_protocol(file_path))
  
      # Two blocks.
      df2 = pd.DataFrame({"one": [4, 5, 6], "two": ["e", "f", "g"]})
      ds = ray.data.from_pandas([df, df2])
      ds._set_uuid("data")
      ds.write_json(data_path, filesystem=fs)
  
      for read_jsonl in [False, True]:
          if fs is None and read_jsonl:
              # Rename input files extension to .jsonl when testing local files.
              # This is to test reading JSONL files.
              for file_name in os.listdir(data_path):
                  old_file_path = os.path.join(data_path, file_name)
                  new_file_path = old_file_path.replace(
                      ".json", ".jsonl"
                  )
                  os.rename(old_file_path, new_file_path)
          else:
              ds2 = ray.data.read_json(
                  data_path, parallelism=2, filesystem=fs
              )
          ds2df = ds2.to_pandas()
          assert pd.concat([df, df2], ignore_index=True).equals(ds2df)
          # Test metadata ops.
          for (
              block,
              meta,
          ) in ds2._plan.execute().get_blocks_with_metadata():
              BlockAccessor.for_block(
                  ray.get(block)
              ).size_bytes() == meta.size_bytes
  
imports: import json
  import os
  import shutil
  from functools import partial
  import pandas
  import pyarrow
  import pyarrow.json
  import pytest
  from pytest_lazyfixture import lazy_fixture
  import ray
  from ray.data.block import BlockAccessor
  from ray.data.datasource import BaseFileMetadataProvider, FastFileMetadataProvider, PartitionStyle, PathPartitionFilter
  from ray.data.datasource.path_util import _unwrap_protocol
  from ray.data.tests.conftest import *
  from ray.data.tests.mock_http_server import *
  from ray.data.tests.test_partitioning import PathPartitionEncoder
  from ray.data.tests.util import Counter
  from ray.tests.conftest import *
label_desc: Use image node_id 10 for calling a global function with example usage: test_json_roundtrip(ray_start_regular_shared, fs, data_path) without return types