P1sec / pycrate

A Python library to ease the development of encoders and decoders for various protocols and file formats; contains ASN.1 and CSN.1 compilers.
GNU Lesser General Public License v2.1
380 stars 130 forks source link

New msg object initialize with from_json, not all data is getting updated #253

Open vbipin opened 6 months ago

vbipin commented 6 months ago

When creating a new msg object and using from_json to fill the data, all of the json data is not getting updated. Is there an easy way to solve this. I am using the pycrate 0.7 and python 3.11

1) Create a sample json text to use.

pdu = unhexlify( '074300035200c2' ) # EMM Attach Complete
m, e = parse_NAS_MT(pdu)
att_complete_json = m.to_json()
print( att_complete_json )

2) I want to create a new message with this json

new_msg = EMMAttachComplete()
new_msg.from_json( att_complete_json )
print( new_msg.to_json() )

The new_msg json is different and also the new_msg.to_bytes()

print ( hexlify( new_msg.to_bytes() )) "07430003000000" this is different from the starting pdu.

mitshell commented 4 months ago

Thanks for bringing this issue. A new pycrate repository has been setup, including new fixes. This repo will keep being maintained : https://github.com/pycrate-org/pycrate. Please checkout the latest 0.7.1 version which provides extended JSON support for mobile NAS messages, what should fix your case (I hope).