control identifier output Tree format need to be converted into Json format

Viewed 106

When we get the print control identifier, the output is in a tree format. Is there a way to print the control identifier output in JSON format.

Current output:

Dialog - 'SP- HS'    (L-32000, T-32000, R-31840, B-31972)
['Dialog', 'SP- HSDialog', 'SP- HS']
child_window(title="SP- HS", class_name="#32770")
   | 
   | Static - 'SP'    (L-31885, T-31977, R-31641, B-31948)
   | ['Static', 'SP', 'SPStatic', 'Static0', 'Static1']
   | child_window(title="SP", class_name="Static")
   | 
   | Static - 'HS'    (L-31526, T-31977, R-30807, B-31946)
   | ['HSStatic', 'HS', 'Static2', 'HSStatic0', 'HSStatic1']
   | child_window(title="HS", class_name="Static")

Desired output:

[{
    "Name": "SP-HS",
    "co-ordinates": "L-32000, T-32000, R-31840, B-31972",
    "Alias": "['Dialog', 'SP- HSDialog', 'SP- HS']",
    "Title": "SP-HP",
    "Class_name": "#32770"
}, {
    "Name": "SP",
    "co-ordinates": "L-31885, T-31977, R-31641, B-31948",
    "Alias": " ['Static', 'SP', 'SPStatic', 'Static0', 'Static1']",
    "Title": "SP",
    "Class_name": "Static"
}]

I know the hard way, where we use all the string manipulation operation and convert this to JSON. But if there any other easier way, let me know .

0 Answers
Related