Closed saharNooby closed 3 years ago
Yes, very true. We should probably switch to using forward slashes on windows too as that works perfectly fine in python.
Sounds more like a mhapi problem. I've tested default json.dumps (on Linux) and IMHO it should do the escaping correctly, even on a Windows machine.
Quote from mhapi:
Why is the encoding routine even necessary? Why not simply use the json.dumps function already available in the imported json library?
Largely, this is because we want to format the floats with eight decimals no matter where in the hierarchy they appear, including converting strings containing numbers into real numbers.
Not sure if there isn't a better solution for that. I'd recommend to use the JSONEncoder class. See the official docs (https://docs.python.org/3/library/json.html): Extending JSONEncoder.
I've provided a new version of version of JsonCall using the standard json library. You need to update mhapi. It's in the Aranuvir branch. Hopefully it does the string encoding/escaping correctly, now. I did not test it on Windows, yet! Perhaps someone could do this for me. Thanks.
@OP: We have updated mhapi, does this fix your issue? Can we close?
I'll test it today
Works good with new JsonCall.py
, reverse slashes are escaped. Thanks!
JsonCall
.serialize
produces invalid JSON. Specifically, reverse slashes in strings\
are not escaped.Reproducing:
getBodyMaterialInfo
to receive material data"materialFile": "E:\Apps\makehuman-1.2.0\makehuman\data\skins\young_caucasian_male\young_caucasian_male2.mhmat",
are not escapedThis prevents working with MakeHuman socket using libraries like GSON.
I don't know whether the fix will break Blender plugin compatibility, so won't do a pull request.
Ugly workaround for clients until fix (or if fix is not possible):