Created
October 25, 2021 05:51
-
-
Save thangarajan8/646b658d1ee70ed6fa48f1307d19375b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import javalang as jl | |
tree = jl.parse.parse(content) | |
def json_ast_encoder(o): | |
if type(o) is set and len(o) == 0: | |
return [] | |
if hasattr(o, "__dict__"): | |
return o.__dict__ | |
return "" | |
v = json.dumps(tree, sort_keys=True, default=json_ast_encoder) | |
y = json.loads(v)['types'][0]['body'] | |
z = json.dumps(y) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment