nodes: 0, module; 1, function_definition; 2, function_name:save_json; 3, parameters; 4, block; 5, identifier:val; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, if_statement; 11, if_statement; 12, if_statement; 13, return_statement; 14, identifier:pretty; 15, False; 16, identifier:sort; 17, True; 18, identifier:encoder; 19, None; 20, comment:"""
      Save data to json string
  
      :param val: Value or struct to save
      :type val: None | int | float | str | list | dict
      :param pretty: Format data to be readable (default: False)
                      otherwise going to be compact
      :type pretty: bool
      :param sort: Sort keys (default: True)
      :type sort: bool
      :param encoder: Use custom json encoder
      :type encoder: T <= DateTimeEncoder
      :return: The jsonified string
      :rtype: str | unicode
      """; 21, comparison_operator:encoder is None; 22, block; 23, identifier:pretty; 24, block; 25, else_clause; 26, boolean_operator; 27, block; 28, identifier:data; 29, identifier:encoder; 30, None; 31, expression_statement; 32, expression_statement; 33, block; 34, not_operator; 35, call; 36, expression_statement; 37, assignment; 38, assignment; 39, expression_statement; 40, comparison_operator:sys.version_info > (3, 0); 41, identifier:isinstance; 42, argument_list; 43, assignment; 44, identifier:encoder; 45, identifier:DateTimeEncoder; 46, identifier:data; 47, call; 48, assignment; 49, attribute; 50, tuple; 51, identifier:data; 52, identifier:str; 53, identifier:data; 54, call; 55, attribute; 56, argument_list; 57, identifier:data; 58, call; 59, identifier:sys; 60, identifier:version_info; 61, integer:3; 62, integer:0; 63, attribute; 64, argument_list; 65, identifier:json; 66, identifier:dumps; 67, identifier:val; 68, keyword_argument; 69, keyword_argument; 70, keyword_argument; 71, keyword_argument; 72, attribute; 73, argument_list; 74, identifier:data; 75, identifier:decode; 76, string:"utf-8"; 77, identifier:indent; 78, integer:4; 79, identifier:separators; 80, tuple; 81, identifier:sort_keys; 82, identifier:sort; 83, identifier:cls; 84, identifier:encoder; 85, identifier:json; 86, identifier:dumps; 87, identifier:val; 88, keyword_argument; 89, keyword_argument; 90, keyword_argument; 91, string; 92, string; 93, identifier:separators; 94, tuple; 95, identifier:sort_keys; 96, identifier:sort; 97, identifier:cls; 98, identifier:encoder; 99, string_content:,; 100, string_content::; 101, string; 102, string; 103, string_content:,; 104, string_content::
code: def save_json(val, pretty=False, sort=True, encoder=None):
      """
      Save data to json string
  
      :param val: Value or struct to save
      :type val: None | int | float | str | list | dict
      :param pretty: Format data to be readable (default: False)
                      otherwise going to be compact
      :type pretty: bool
      :param sort: Sort keys (default: True)
      :type sort: bool
      :param encoder: Use custom json encoder
      :type encoder: T <= DateTimeEncoder
      :return: The jsonified string
      :rtype: str | unicode
      """
      if encoder is None:
          encoder = DateTimeEncoder
      if pretty:
          data = json.dumps(
              val,
              indent=4,
              separators=(',', ': '),
              sort_keys=sort,
              cls=encoder
          )
      else:
          data = json.dumps(
              val,
              separators=(',', ':'),
              sort_keys=sort,
              cls=encoder
          )
      if not sys.version_info > (3, 0) and isinstance(data, str):
          data = data.decode("utf-8")
      return data