Matmaus / LnkParse3

Windows Shortcut file (LNK) parser
MIT License
71 stars 13 forks source link

JSON Formatting Options ? #19

Closed Compr0mzd closed 1 year ago

Compr0mzd commented 1 year ago

Would it be possible instead of printing the json to stdout to make a usable json object ?

Matmaus commented 1 year ago

Hi, thanks for the question. You can use method get_json() instead of print_json(). See example below:

>>> import LnkParse3
>>> with open('tests/samples/microsoft_example', 'rb') as indata:
>>>    lnk = LnkParse3.lnk_file(indata)
>>>    json_repr = lnk.get_json()
>>>    json_repr['link_info']['location_info']['drive_type']
'DRIVE_FIXED'
>>>

Is it what you were thinking about?

I see it could be useful to create API documentation :slightly_smiling_face:

Compr0mzd commented 1 year ago

Hi, thanks for the question. You can use method get_json() instead of print_json(). See example below:

>>> import LnkParse3
>>> with open('tests/samples/microsoft_example', 'rb') as indata:
>>>    lnk = LnkParse3.lnk_file(indata)
>>>    json_repr = lnk.get_json()
>>>    json_repr['link_info']['location_info']['drive_type']
'DRIVE_FIXED'
>>>

Is it what you were thinking about?

I see it could be useful to create API documentation 🙂

Hey I appreciate the fast reply. Indeed I found the get_json() function afterwards and was doing some testings. I'm trying to do bulk parsing on a lot of lnk files. It seems there is some json formatting issues when i try to send them to a splunk server

Matmaus commented 1 year ago

It seems there is some json formatting issues when i try to send them to a splunk server

Would it be possible to provide some file(s) with issues? I can look what is the problem.

Compr0mzd commented 1 year ago

Sorry for the missleading issue it seems my json are indeed correct and my issue is regarding the conversion of these files to python dict which introduce empty key pair value.