code: def test_figure_json_encoding(self):
      df = pd.DataFrame(columns=["col 1"], data=[1, 2, 3])
      s1 = Scatter3d(x=numeric_list, y=np_list, z=mixed_list)
      s2 = Scatter(x=df["col 1"])
      data = Data([s1, s2])
      figure = Figure(data=data)
  
      js1 = _json.dumps(s1, cls=utils.PlotlyJSONEncoder, sort_keys=True)
      js2 = _json.dumps(s2, cls=utils.PlotlyJSONEncoder, sort_keys=True)
  
      assert (
          js1 == '{"type": "scatter3d", "x": [1, 2, 3], '
          '"y": [1, 2, 3, null, null, null, "2014-01-05T00:00:00"], '
          '"z": [1, "A", "2014-01-05T00:00:00", '
          '"2014-01-05T01:01:01", "2014-01-05T01:01:01.000001"]}'
      )
      assert js2 == '{"type": "scatter", "x": [1, 2, 3]}'
  
      # Test JSON encoding works
      _json.dumps(data, cls=utils.PlotlyJSONEncoder, sort_keys=True)
      _json.dumps(figure, cls=utils.PlotlyJSONEncoder, sort_keys=True)
  
      # Test data wasn't mutated
      np_array = np.array(
          [1, 2, 3, np.NaN, np.NAN, np.Inf, dt(2014, 1, 5)]
      )
      for k in range(len(np_array)):
          if k in [3, 4]:
              # check NaN
              assert np.isnan(np_list[k]) and np.isnan(np_array[k])
          else:
              # non-NaN
              assert np_list[k] == np_array[k]
  
      assert set(data[0]["z"]) == set(
          [
              1,
              "A",
              dt(2014, 1, 5),
              dt(2014, 1, 5, 1, 1, 1),
              dt(2014, 1, 5, 1, 1, 1, 1),
          ]
      )
  
imports: import datetime
  import math
  import decimal
  from datetime import datetime
  from unittest import TestCase
  from time import time
  import pytest
  import numpy
  import pandas
  import pytz
  from pandas.testing import assert_series_equal
  import json
  import os
  import base64
  from plotly import optional_imports, utils
  import plotly.graph_objects
  from plotly.graph_objs import Scatter, Scatter3d, Figure, Data
  from plotly.utils import get_by_path
  from PIL import Image
label_desc: Use image node_id 10 for calling the TestJSONEncoder obj's underlying member method code with example usage: obj.test_figure_json_encoding() without return types