-
Notifications
You must be signed in to change notification settings - Fork 42
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
Add support for additional python types as dict keys in Struct.to_json #321
Add support for additional python types as dict keys in Struct.to_json #321
Conversation
Should we? |
Would require us to import enums module in csp, as we would need to check if a python object is an enum type. |
It's possible to check if the type is a subclass of a python enum, let me see how ugly it is. On unhandled type, should we default to str? |
Yes, it should be. |
Signed-off-by: Arham Chopra <[email protected]>
775cf61
to
3332483
Compare
Added support for python enums in the latest push |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix typo in docs
Signed-off-by: Arham Chopra <[email protected]>
a7db187
to
92be596
Compare
Point72#321) * Add support for additional python types as dict keys in Struct.to_json Signed-off-by: Arham Chopra <[email protected]> * Fix memory leaks, add docs, and address comments Signed-off-by: Arham Chopra <[email protected]> --------- Signed-off-by: Arham Chopra <[email protected]>
const char * str = PyUnicode_AsUTF8AndSize( str_obj.get(), &len ); | ||
val.SetString( str, len, doc.GetAllocator() ); | ||
} | ||
else if( PyUnicode_Check( py_key ) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might want to check string first since that is by far the most common
This PR adds support for more python types to be keys of a dictionary in the csp.Struct's to_json method.
Previously there was support for:
With this PR, the following additional types will be handled: