class_docstr: Meant to be passed as the `cls` kwarg to json.dumps(obj, cls=..)
  
  See PlotlyJSONEncoder.default for more implementation information.
  
  Additionally, this encoder overrides nan functionality so that 'Inf',
  'NaN' and '-Inf' encode to 'null'. Which is stricter JSON than the Python
  version.
class_docstr_tok: ["Meant","to","be","passed","as","the","`","cls","`","kwarg","to","json.dumps","(","obj",",","cls=","..",")","See","PlotlyJSONEncoder.default","for","more","implementation","information",".","Additionally",",","this","encoder","overrides","nan","functionality","so","that","'Inf","'",",","'NaN","'","and","'-Inf","'","encode","to","'null","'",".","Which","is","stricter","JSON","than","the","Python","version","."]
docstr: Accept an object (of unknown type) and try to encode with priority:
  1. builtin:     user-defined objects
  2. sage:        sage math cloud
  3. pandas:      dataframes/series
  4. numpy:       ndarrays
  5. datetime:    time/datetime objects
  
  Each method throws a NotEncoded exception if it fails.
  
  The default method will only get hit if the object is not a type that
  is naturally encoded by json:
  
      Normal objects:
          dict                object
          list, tuple         array
          str, unicode        string
          int, long, float    number
          True                true
          False               false
          None                null
  
      Extended objects:
          float('nan')        'NaN'
          float('infinity')   'Infinity'
          float('-infinity')  '-Infinity'
  
  Therefore, we only anticipate either unknown iterables or values here.
docstr_tok: ["Accept","an","object","(","of","unknown","type",")","and","try","to","encode","with","priority",":","1.","builtin",":","user-defined","objects","2.","sage",":","sage","math","cloud","3.","pandas",":","dataframes\/series","4.","numpy",":","ndarrays","5.","datetime",":","time\/datetime","objects","Each","method","throws","a","NotEncoded","exception","if","it","fails",".","The","default","method","will","only","get","hit","if","the","object","is","not","a","type","that","is","naturally","encoded","by","json",":","Normal","objects",":","dict","object","list",",","tuple","array","str",",","unicode","string","int",",","long",",","float","number","True","true","False","false","None","null","Extended","objects",":","float","(","'nan","'",")","'NaN'","float","(","'infinity","'",")","'Infinity'","float","(","'-infinity","'",")","'-Infinity'","Therefore",",","we","only","anticipate","either","unknown","iterables","or","values","here","."]
code: def default(self, obj):
      """
      Accept an object (of unknown type) and try to encode with priority:
      1. builtin:     user-defined objects
      2. sage:        sage math cloud
      3. pandas:      dataframes/series
      4. numpy:       ndarrays
      5. datetime:    time/datetime objects
  
      Each method throws a NotEncoded exception if it fails.
  
      The default method will only get hit if the object is not a type that
      is naturally encoded by json:
  
          Normal objects:
              dict                object
              list, tuple         array
              str, unicode        string
              int, long, float    number
              True                true
              False               false
              None                null
  
          Extended objects:
              float('nan')        'NaN'
              float('infinity')   'Infinity'
              float('-infinity')  '-Infinity'
  
      Therefore, we only anticipate either unknown iterables or values here.
  
      """
      # TODO: The ordering if these methods is *very* important. Is this OK?
      encoding_methods = (
          self.encode_as_plotly,
          self.encode_as_sage,
          self.encode_as_numpy,
          self.encode_as_pandas,
          self.encode_as_datetime,
          self.encode_as_date,
          self.encode_as_list,  # because some values have `tolist` do last.
          self.encode_as_decimal,
          self.encode_as_pil,
      )
      for encoding_method in encoding_methods:
          try:
              return encoding_method(obj)
          except NotEncodable:
              pass
      return _json.JSONEncoder.default(self, obj)
  
imports: import decimal
  import json
  import sys
  import re
  from functools import reduce
  from _plotly_utils.optional_imports import get_module
  from _plotly_utils.basevalidators import ImageUriValidator
label_desc: Use image node_id 3 for calling the PlotlyJSONEncoder obj's underlying member method code with example usage: obj.default(obj) and returns: _json, encoding_method