class_docstr: Structured parse results, to provide multiple means of access to
  the parsed data:
  
  - as a list (``len(results)``)
  - by list index (``results[0], results[1]``, etc.)
  - by attribute (``results.<results_name>`` - see :class:`ParserElement.set_results_name`)
  
  Example::
  
      integer = Word(nums)
      date_str = (integer.set_results_name("year") + '/'
                  + integer.set_results_name("month") + '/'
                  + integer.set_results_name("day"))
      # equivalent form:
      # date_str = (integer("year") + '/'
      #             + integer("month") + '/'
      #             + integer("day"))
  
      # parse_string returns a ParseResults object
      result = date_str.parse_string("1999/12/31")
  
      def test(s, fn=repr):
          print(f"{s} -> {fn(eval(s))}")
      test("list(result)")
      test("result[0]")
      test("result['month']")
      test("result.day")
      test("'month' in result")
      test("'minutes' in result")
      test("result.dump()", str)
  
  prints::
  
      list(result) -> ['1999', '/', '12', '/', '31']
      result[0] -> '1999'
      result['month'] -> '12'
      result.day -> '31'
      'month' in result -> True
      'minutes' in result -> False
      result.dump() -> ['1999', '/', '12', '/', '31']
      - day: '31'
      - month: '12'
      - year: '1999'
class_docstr_tok: ["Structured","parse","results",",","to","provide","multiple","means","of","access","to","the","parsed","data",":","-","as","a","list","(","``","len","(","results",")","``",")","-","by","list","index","(","``","results","[","0","]",",","results","[","1","]","``",",","etc",".",")","-","by","attribute","(","``","results.","<","results_name",">","``","-","see",":","class",":","`","ParserElement.set_results_name","`",")","Example",":",":","integer","=","Word","(","nums",")","date_str","=","(","integer.set_results_name","(","``","year","''",")","+","'\/'","+","integer.set_results_name","(","``","month","''",")","+","'\/'","+","integer.set_results_name","(","``","day","''",")",")","#","equivalent","form",":","#","date_str","=","(","integer","(","``","year","''",")","+","'\/'","#","+","integer","(","``","month","''",")","+","'\/'","#","+","integer","(","``","day","''",")",")","#","parse_string","returns","a","ParseResults","object","result","=","date_str.parse_string","(","``","1999\/12\/31","''",")","def","test","(","s",",","fn=repr",")",":","print","(","f","''","{","s","}","-",">","{","fn","(","eval","(","s",")",")","}","''",")","test","(","``","list","(","result",")","''",")","test","(","``","result","[","0","]","''",")","test","(","``","result","[","'month","'","]","''",")","test","(","``","result.day","''",")","test","(","``","'month","'","in","result","''",")","test","(","``","'minutes","'","in","result","''",")","test","(","``","result.dump","(",")","''",",","str",")","prints",":",":","list","(","result",")","-",">","[","'1999","'",",","'\/","'",",","'12","'",",","'\/","'",",","'31","'","]","result","[","0","]","-",">","'1999'","result","[","'month","'","]","-",">","'12'","result.day","-",">","'31'","'month","'","in","result","-",">","True","'minutes","'","in","result","-",">","False","result.dump","(",")","-",">","[","'1999","'",",","'\/","'",",","'12","'",",","'\/","'",",","'31","'","]","-","day",":","'31'","-","month",":","'12'","-","year",":","'1999","'"]
docstr: Returns the named parse results as a nested dictionary.
  
  Example::
  
      integer = Word(nums)
      date_str = integer("year") + '/' + integer("month") + '/' + integer("day")
  
      result = date_str.parse_string('12/31/1999')
      print(type(result), repr(result)) # -> <class 'pyparsing.ParseResults'> (['12', '/', '31', '/', '1999'], {'day': [('1999', 4)], 'year': [('12', 0)], 'month': [('31', 2)]})
  
      result_dict = result.as_dict()
      print(type(result_dict), repr(result_dict)) # -> <class 'dict'> {'day': '1999', 'year': '12', 'month': '31'}
  
      # even though a ParseResults supports dict-like access, sometime you just need to have a dict
      import json
      print(json.dumps(result)) # -> Exception: TypeError: ... is not JSON serializable
      print(json.dumps(result.as_dict())) # -> {"month": "31", "day": "1999", "year": "12"}
docstr_tok: ["Returns","the","named","parse","results","as","a","nested","dictionary",".","Example",":",":","integer","=","Word","(","nums",")","date_str","=","integer","(","``","year","''",")","+","'\/","'","+","integer","(","``","month","''",")","+","'\/","'","+","integer","(","``","day","''",")","result","=","date_str.parse_string","(","'12\/31\/1999","'",")","print","(","type","(","result",")",",","repr","(","result",")",")","#","-",">","<","class","'pyparsing.ParseResults","'",">","(","[","'12","'",",","'\/","'",",","'31","'",",","'\/","'",",","'1999","'","]",",","{","'day","'",":","[","(","'1999","'",",","4",")","]",",","'year","'",":","[","(","'12","'",",","0",")","]",",","'month","'",":","[","(","'31","'",",","2",")","]","}",")","result_dict","=","result.as_dict","(",")","print","(","type","(","result_dict",")",",","repr","(","result_dict",")",")","#","-",">","<","class","'dict","'",">","{","'day","'",":","'1999","'",",","'year","'",":","'12","'",",","'month","'",":","'31","'","}","#","even","though","a","ParseResults","supports","dict-like","access",",","sometime","you","just","need","to","have","a","dict","import","json","print","(","json.dumps","(","result",")",")","#","-",">","Exception",":","TypeError",":","...","is","not","JSON","serializable","print","(","json.dumps","(","result.as_dict","(",")",")",")","#","-",">","{","``","month","''",":","``","31","''",",","``","day","''",":","``","1999","''",",","``","year","''",":","``","12","''","}"]
code: def as_dict(self) -> dict:
      """
      Returns the named parse results as a nested dictionary.
  
      Example::
  
          integer = Word(nums)
          date_str = integer("year") + '/' + integer("month") + '/' + integer("day")
  
          result = date_str.parse_string('12/31/1999')
          print(type(result), repr(result)) # -> <class 'pyparsing.ParseResults'> (['12', '/', '31', '/', '1999'], {'day': [('1999', 4)], 'year': [('12', 0)], 'month': [('31', 2)]})
  
          result_dict = result.as_dict()
          print(type(result_dict), repr(result_dict)) # -> <class 'dict'> {'day': '1999', 'year': '12', 'month': '31'}
  
          # even though a ParseResults supports dict-like access, sometime you just need to have a dict
          import json
          print(json.dumps(result)) # -> Exception: TypeError: ... is not JSON serializable
          print(json.dumps(result.as_dict())) # -> {"month": "31", "day": "1999", "year": "12"}
      """
  
      def to_item(obj):
          if isinstance(obj, ParseResults):
              return (
                  obj.as_dict()
                  if obj.haskeys()
                  else [to_item(v) for v in obj]
              )
          else:
              return obj
  
      return dict((k, to_item(v)) for k, v in self.items())
  
imports: from collections.abc import MutableMapping, Mapping, MutableSequence, Iterator, Sequence, Container
  import pprint
  from typing import Tuple, Any, Dict, Set, List
label_desc: Use image node_id 29 for calling the ParseResults obj's underlying member method code with example usage: obj.as_dict() and returns: dict, unknown, obj