-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expand JSON Serialization to entire object #97
Comments
|
Do we need to specify which fields need to be base64 encoded or is it clear from specifying a u8 array vs a string? |
There's been problems with the strings in the past, since they're actually 20-byte arrays that are null terminated - the extra bytes screw up the serialization. I'll try and see if there's an easy way to eliminate augmenting the specs - but not sure yet. |
For posterity, here's the hack I did during the hackathon to find serialization issues: +def todict(obj, classkey=None):
+ if isinstance(obj, dict):
+ data = {}
+ for (k, v) in obj.items():
+ data[k] = todict(v, classkey)
+ return data
+ elif hasattr(obj, "_ast"):
+ return todict(obj._ast())
+ elif hasattr(obj, "__iter__"):
+ return [todict(v, classkey) for v in obj]
+ elif hasattr(obj, "__dict__"):
+ if hasattr(obj, "payload"):
+ obj.payload = base64.standard_b64encode(obj.payload)
+ if hasattr(obj, "name"):
+ obj.name = base64.standard_b64encode(obj.name)
+ data = dict([(key, todict(value, classkey))
+ for key, value in obj.__dict__.iteritems()
+ if not callable(value) and not key.startswith('_')])
+ if classkey is not None and hasattr(obj, "__class__"):
+ data[classkey] = obj.__class__.__name__
+ return data
+ else:
+ return obj |
Completed. Note, did not have to augment the message yamls to identity areas that needed base64 encoding. |
We need full JSON serialization of the SBP messages. Presently, just the SBP base message is being JSON serialized. Some binary fields will need to be base64 encoded.
The text was updated successfully, but these errors were encountered: