22"""SparkData base-class; models Spark JSON objects as native Python objects.
33
44The SparkData class models any JSON object passed to it as a string or Python
5- dictionary as a native Python object; providing attribute access access using
6- native object.attribute syntax .
5+ dictionary as a native Python object; providing attribute access using native
6+ dot-syntax (` object.attribute`) .
77
88SparkData is intended to serve as a base-class, which provides inheritable
99functionality, for concrete sub-classes that model specific Cisco Spark data
1414to objects by the Cisco Spark cloud.
1515
1616Example:
17- >>> json_obj = '{"created": "2012-06-15T20:36:48.914Z",
18- "displayName": "Chris Lunsford (chrlunsf)",
19- "id": "Y2lzY29zcGFyazovL3VzL1BFT1BMRS9mZjhlZTZmYi1hZm ...",
20- "avatar": "https://1efa7a94ed216783e352-c622665287144 ...",
21- "emails": ["chrlunsf@cisco.com"]}'
17+ >>> json_obj = ''' {"created": "2012-06-15T20:36:48.914Z",
18+ "displayName": "Chris Lunsford (chrlunsf)",
19+ "id": "Y2lzY29zcGFyazovL3VzL1BFT1BMRS9mZjhlZTZmYi1h ...",
20+ "avatar": "https://1efa7a94ed216783e352-c6226652871 ...",
21+ "emails": ["chrlunsf@cisco.com"]}'' '
2222 >>> python_obj = SparkData(json_obj)
2323 >>> python_obj.displayName
2424 u'Chris Lunsford (chrlunsf)'
4848
4949
5050def _json_dict (json ):
51- """Given a JSON dictionary or string; return a dictionary.
51+ """Given a dictionary or JSON string; return a dictionary.
5252
5353 Args:
5454 json(dict, str): Input JSON object.
@@ -74,7 +74,7 @@ class SparkData(object):
7474 """Model Spark JSON objects as native Python objects."""
7575
7676 def __init__ (self , json ):
77- """Init a new SparkData object from a JSON dictionary or string.
77+ """Init a new SparkData object from a dictionary or JSON string.
7878
7979 Args:
8080 json(dict, str): Input JSON object.
@@ -87,7 +87,7 @@ def __init__(self, json):
8787 self ._json = _json_dict (json )
8888
8989 def __getattr__ (self , item ):
90- """Provide native attribute access to the JSON object's attributes.
90+ """Provide native attribute access to the JSON object attributes.
9191
9292 This method is called when attempting to access a object attribute that
9393 hasn't been defined for the object. For example trying to access
0 commit comments