Intro.
I have a C++ application, I use SWIG to launch GetObjects
and PutObjects
methods which are defined in python code. GetObjects
method opens JSON formated file, takes objects from there and returns back them to C++ application. While the PutObjects
method gets objects from C++ application, opens JSON formated file for writing and stores them over there.
The code is pretty common and uses MyJSONDecode and MyJSONEncode functions to interact between python objects and json dictionaries.
Now the problem.
Swig converts MyObject
C++ class into python class called MyObject
located in abc
module. I use import abc
statement to use it further in code like abc.MyObject()
.
abc.MyObject
is a SwigPyObject
and it does not have dictionary itself (__dict__
member).
So I can't iterate through MyObject.__dict__
inside MyJSONEncode function to build up a dictionary which should be returned by the function and therefore to create a JSON format.
But MyObject has properties, for example url or name and so on. How can I iterate through properties ?
If needed, I will provide you with code. Just let me know. Also I hope, in general, my problem is understood.
Waiting for kind response :)