Table of Contents
- use dot-tab-dot-tab to read big-json-like-struct
- dot-chain-view
$ pip3 install eobj
- lower-case-greece-chars cant appear in keys
- because lower-case-greece-chars is used as control-chars in the-py-code
- refer to NOT-ALLOWED-CHARS-IN-KEY and ATTRIBUTE-NAMES
from eobj.eobj import jobj2orb from eobj.eobj import wfstree,sdfstree,edfstree,wfs_brackets,sdfs_brackets,edfs_brackets import esprima jobj = esprima.parse("function tst() {a = b}").toDict() { type: "Program", sourceType: "script", body: [ { type: "FunctionDeclaration", expression: False, isAsync: False, id: { type: "Identifier", name: "tst" }, params: [], body: { type: "BlockStatement", body: [ { type: "ExpressionStatement", expression: { type: "AssignmentExpression", operator: "=", left: { type: "Identifier", name: "a" }, right: { type: "Identifier", name: "b" } } } ] }, generator: False } ] } o = jobj2orb(jobj) >>> o. o. o.body o.sourceType o.type >>> o.body. o.body. o.body.l0_ >>> o.body.l0_. o.body.l0_. o.body.l0_.body o.body.l0_.generator o.body.l0_.params o.body.l0_.async o.body.l0_.expression o.body.l0_.id o.body.l0_.type >>> o.body.l0_.body. o.body.l0_.body. o.body.l0_.body.body o.body.l0_.body.type >>> o.body.l0_.body.type 'BlockStatement' >>> from xdict.jprint import pobj >>> pobj(o.body.l0_.body.body.l0_.expression) >>> o.body.l0_.body.body.l0_.expression {'type': 'AssignmentExpression', 'operator': '=', 'left': {'type': 'Identifier', 'name': 'a'}, 'right': {'type': 'Identifier', 'name': 'b'}} >>> { 'type': 'AssignmentExpression', 'operator': '=', 'left': { 'type': 'Identifier', 'name': 'a' }, 'right': { 'type': 'Identifier', 'name': 'b' } } >>>
wfstree(o)
wfstree(o,2,4)
>>> wfstree(o) type sourceType body body.l0_ body.l0_.type body.l0_.expression body.l0_.async body.l0_.id body.l0_.params body.l0_.body body.l0_.generator body.l0_.id.type body.l0_.id.name body.l0_.body.type body.l0_.body.body body.l0_.body.body.l0_ body.l0_.body.body.l0_.type body.l0_.body.body.l0_.expression body.l0_.body.body.l0_.expression.type body.l0_.body.body.l0_.expression.operator body.l0_.body.body.l0_.expression.left body.l0_.body.body.l0_.expression.right body.l0_.body.body.l0_.expression.left.type body.l0_.body.body.l0_.expression.left.name body.l0_.body.body.l0_.expression.right.type body.l0_.body.body.l0_.expression.right.name >>> wfstree(o,2,4) body.l0_ body.l0_.type body.l0_.expression body.l0_.async body.l0_.id body.l0_.params body.l0_.body body.l0_.generator >>>
sdfstree(o)
sdfstree(o,3,5)
>>> sdfstree(o) type sourceType body body.l0_ body.l0_.type body.l0_.expression body.l0_.async body.l0_.id body.l0_.id.type body.l0_.id.name body.l0_.params body.l0_.body body.l0_.body.type body.l0_.body.body body.l0_.body.body.l0_ body.l0_.body.body.l0_.type body.l0_.body.body.l0_.expression body.l0_.body.body.l0_.expression.type body.l0_.body.body.l0_.expression.operator body.l0_.body.body.l0_.expression.left body.l0_.body.body.l0_.expression.left.type body.l0_.body.body.l0_.expression.left.name body.l0_.body.body.l0_.expression.right body.l0_.body.body.l0_.expression.right.type body.l0_.body.body.l0_.expression.right.name body.l0_.generator >>> sdfstree(o,3,5) body.l0_.type body.l0_.expression body.l0_.async body.l0_.id body.l0_.id.type body.l0_.id.name body.l0_.params body.l0_.body body.l0_.body.type body.l0_.body.body body.l0_.generator >>>
edfstree(o)
edfstree(o,3,5)
>>> edfstree(o) type sourceType body.l0_.type body.l0_.expression body.l0_.async body.l0_.id.type body.l0_.id.name body.l0_.id body.l0_.params body.l0_.body.type body.l0_.body.body.l0_.type body.l0_.body.body.l0_.expression.type body.l0_.body.body.l0_.expression.operator body.l0_.body.body.l0_.expression.left.type body.l0_.body.body.l0_.expression.left.name body.l0_.body.body.l0_.expression.left body.l0_.body.body.l0_.expression.right.type body.l0_.body.body.l0_.expression.right.name body.l0_.body.body.l0_.expression.right body.l0_.body.body.l0_.expression body.l0_.body.body.l0_ body.l0_.body.body body.l0_.body body.l0_.generator body.l0_ body >>> edfstree(o,3,5) body.l0_.type body.l0_.expression body.l0_.async body.l0_.id.type body.l0_.id.name body.l0_.id body.l0_.params body.l0_.body.type body.l0_.body.body body.l0_.body body.l0_.generator >>>
wfs_brackets(o)
wfs_brackets(o,2,4)
>>> wfs_brackets(o) ['type'] ['sourceType'] ['body'] ['body'][0] ['body'][0]['type'] ['body'][0]['expression'] ['body'][0]['async'] ['body'][0]['id'] ['body'][0]['params'] ['body'][0]['body'] ['body'][0]['generator'] ['body'][0]['id']['type'] ['body'][0]['id']['name'] ['body'][0]['body']['type'] ['body'][0]['body']['body'] ['body'][0]['body']['body'][0] ['body'][0]['body']['body'][0]['type'] ['body'][0]['body']['body'][0]['expression'] ['body'][0]['body']['body'][0]['expression']['type'] ['body'][0]['body']['body'][0]['expression']['operator'] ['body'][0]['body']['body'][0]['expression']['left'] ['body'][0]['body']['body'][0]['expression']['right'] ['body'][0]['body']['body'][0]['expression']['left']['type'] ['body'][0]['body']['body'][0]['expression']['left']['name'] ['body'][0]['body']['body'][0]['expression']['right']['type'] ['body'][0]['body']['body'][0]['expression']['right']['name'] >>> wfs_brackets(o,2,4) ['body'][0] ['body'][0]['type'] ['body'][0]['expression'] ['body'][0]['async'] ['body'][0]['id'] ['body'][0]['params'] ['body'][0]['body'] ['body'][0]['generator'] >>>
sdfs_brackets(o)
sdfs_brackets(o,3,5)
>>> sdfs_brackets(o) ['type'] ['sourceType'] ['body'] ['body'][0] ['body'][0]['type'] ['body'][0]['expression'] ['body'][0]['async'] ['body'][0]['id'] ['body'][0]['id']['type'] ['body'][0]['id']['name'] ['body'][0]['params'] ['body'][0]['body'] ['body'][0]['body']['type'] ['body'][0]['body']['body'] ['body'][0]['body']['body'][0] ['body'][0]['body']['body'][0]['type'] ['body'][0]['body']['body'][0]['expression'] ['body'][0]['body']['body'][0]['expression']['type'] ['body'][0]['body']['body'][0]['expression']['operator'] ['body'][0]['body']['body'][0]['expression']['left'] ['body'][0]['body']['body'][0]['expression']['left']['type'] ['body'][0]['body']['body'][0]['expression']['left']['name'] ['body'][0]['body']['body'][0]['expression']['right'] ['body'][0]['body']['body'][0]['expression']['right']['type'] ['body'][0]['body']['body'][0]['expression']['right']['name'] ['body'][0]['generator'] >>> sdfs_brackets(o,3,5) ['body'][0]['type'] ['body'][0]['expression'] ['body'][0]['async'] ['body'][0]['id'] ['body'][0]['id']['type'] ['body'][0]['id']['name'] ['body'][0]['params'] ['body'][0]['body'] ['body'][0]['body']['type'] ['body'][0]['body']['body'] ['body'][0]['generator'] >>>
edfs_brackets(o)
edfs_brackets(o,3,5)
>>> edfs_brackets(o) type sourceType body.l0_.type body.l0_.expression body.l0_.async body.l0_.id.type body.l0_.id.name body.l0_.id body.l0_.params body.l0_.body.type body.l0_.body.body.l0_.type body.l0_.body.body.l0_.expression.type body.l0_.body.body.l0_.expression.operator body.l0_.body.body.l0_.expression.left.type body.l0_.body.body.l0_.expression.left.name body.l0_.body.body.l0_.expression.left body.l0_.body.body.l0_.expression.right.type body.l0_.body.body.l0_.expression.right.name body.l0_.body.body.l0_.expression.right body.l0_.body.body.l0_.expression body.l0_.body.body.l0_ body.l0_.body.body body.l0_.body body.l0_.generator body.l0_ body >>> edfs_brackets(o,3,5) body.l0_.type body.l0_.expression body.l0_.async body.l0_.id.type body.l0_.id.name body.l0_.id body.l0_.params body.l0_.body.type body.l0_.body.body body.l0_.body body.l0_.generator >>>
- ['α', 'β', 'γ', 'δ', 'ε', 'ζ', 'η', 'θ', 'ι', 'κ', 'λ', 'μ', 'ν', 'ξ', 'ο', 'π', 'ρ', 'σ', 'τ', 'υ', 'φ', 'χ', 'ψ', 'ω']
l0_,l1_,l2_... means list-element
t0_,t1_,t2_... means tuple-element
s0_,s1_,s2_... means set-element
σ0,σ1,σ2 means keys-begin-with-a-number,which-is-not-permitted-in-attribute-name
>>> from eobj.eobj import jobj2orb >>> from eobj.eobj import wfstree,sdfstree,edfstree,wfs_brackets,sdfs_brackets,edfs_brackets >>> >>> >>> jobj = { ... 0:"zero", ... 1:"one" ... } >>> >>> o = jobj2orb(jobj) >>> o. o. o.σ0 o.σ1 >>> o.σ0 'zero' >>> o.σ1 'one' >>>
θ means dash-in-keys
>>> jobj = { ... "a-b":"zero", ... "b-c":"one" ... } >>> >>> >>> o = jobj2orb(jobj) >>> o. o. o.aθb o.bθc >>> o.aθb 'zero' >>> o.bθc 'one' >>>
ε means space-in-keys
>>> jobj = { ... "a b":"zero", ... "b c":"one" ... } >>> >>> o = jobj2orb(jobj) >>> o. o. o.aεb o.bεc >>> o.aεb 'zero' >>> o.bεc 'one' >>>
π means pounds-in-keys
>>> jobj = { ... "a#b":"zero", ... "b#c":"one" ... } >>> o = jobj2orb(jobj) >>> o. o. o.aπb o.bπc >>> o.aπb 'zero' >>> o.bπc 'one' >>>
λ means underscore
>>> jobj = { ... "a_b":"zero", ... "b_c":"one" ... } >>> >>> o = jobj2orb(jobj) >>> >>> o. o. o.aλb o.bλc >>> o.aλb 'zero' >>> o.bλc 'one' >>>
others will-be-urlquoted
>>> jobj = { ... "a@\x00b":"zero", ... "b@\x00c":"one" ... } >>> o = jobj2orb(jobj) >>> o. o. o.aψ40ψ00b o.bψ40ψ00c >>> o.aψ40ψ00b 'zero' >>> o.bψ40ψ00c 'one' >>>
- MIT