Package jsondata :: Module JSONTree :: Class JSONTree
[hide private]
[frames] | no frames]

Class JSONTree

source code


Instance Methods [hide private]
 
__init__(self, **kargs)
Create an object for the tree representation.
source code
 
printDiff(self)
Prints out the resulting list of differences.
source code
 
fetchDiff(self, n0, n1, p=[], dl=0)
Recursive tree compare for Python trees as used for the package 'json'.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, **kargs)
(Constructor)

source code 
Create an object for the tree representation.

Args:
    **kargs: Parameter specific for the operation,

        scope:
        
            * all: Display all diffs.
            * first: Display first diff only.
            
            default:=first
    
        charset:
        
            * raw: Use 'raw'.
            * str: Use 'str'.
            * utf: Use 'utf'.
            
            default:=raw

        debug:

            Add developer information.

        linefit:
            
            * cut: Cut lines to length.
            * wrap: Split lines to length.

            default:=wrap

        indent=#numchars:

            Number of characters for indentation.

        linewidth=#numchars:

            Length of lines.

        verbose:

            Add progress and status dialogue output.

Returns:
    When successful returns 'True', else raises an exception.

Raises:
    passed through exceptions:
    

Overrides: object.__init__

printDiff(self)

source code 
Prints out the resulting list of differences.

Args:
     ffs.

Returns:
    When successful returns tree represantation.

Raises:
    passed through exceptions:

fetchDiff(self, n0, n1, p=[], dl=0)

source code 
Recursive tree compare for Python trees as used for the package 'json'.

Finds diff in native Python trees assembled by the standard package 'json'
and compatible, e.g. 'ujson'.


* leveltop
* levelbottom
* delta (for containers)
* scope(all, first)
* linewidth
* displaycharset (str,utf)
* pathonly

Args:

    n0:

        JSON string of type 'str', or 'unicode'

    n1:

        JSON string of type 'str', or 'unicode'

    p=[]:


        Result entries for each difference:
            ::

                {'n0':n0,'n1':n1,'dl':dl,'p':p[:]}

            #. first JSON data
            #. second JSON data
            #. diff count increment value
            #. current diff including path

        List of differences as of:
        
        #. non equal types are different: type(n0) != type(n1)
        #. equal types, both list: type(n0) is list

            #. length is different: len(n0.keys()) != len(n1.keys())
            #. at leats one item is different: n1.get(ni) and v != n1[ni]

        #. equal types, both dict: type(n0) is dict and type(n1) is dict 

            #. length is different: len(n0.keys()) != len(n1.keys())
            #. at leats one item is different: n1.get(ni) and v != n1[ni]

        default:=0

Returns:
    When no diffs returns True, else False or raises an exception.
    The resulting differences are contained in the provided 
    list parameter 'p'. When not provided the resulting list 
    is suppressed. 

Raises:
    passed through exceptions: