So, I'm working on a C library that extends Python, per this page. It's working great, but I want more.
I'm serving up JSON in a string to the Python app, where I'm running json.loads on it. Basically, in the main Python app I'm running
result = json.loads(my_module.get_json_string())
Because I'm only ever going to care about getting the data in Python in a nice Pythonic dictionary form, I'd rather put the json.loads part into my C program. I'd like to do this:
result = my_module.get_result()
And, I'd like to do it using the nice, dependable json module that's already there. How do I do that? I can see how I could do it from C if I were running the interpreter from C, but that's not what I'm doing. I want C pseudocode that goes something like this:
- Obtain the json string like I am now
- Call Python to convert it to a Python object using json.loads
- return the Python object
Any pointers (other than to the local mental hospital?)