Replies: 3 comments 5 replies
-
Can you provide full minimal example that fails to compile? |
Beta Was this translation helpful? Give feedback.
-
But why would you do this? I suppose you are familiar with this library.. But what you are doing will inevitable be slow because each little thing you move to json would be copied. I do not have high hopes for general performance of this library either. Urho3D already has |
Beta Was this translation helpful? Give feedback.
-
The point of the files here were to simply make the nlohmann json library automatically convert ea::string to std::string and really only amounts to something cosmetic. The reason why I'm using this json library is because I'm (relatively) familiar with it unlike Urho3D/rbfx, and I usually pluck it into all of my projects that have file I/O. The reason why I would do this at all is because I was having issues figuring out how to serialize my Component attributes ( Ultimately I just didn't use the automatic type conversion functions and simply bypassed the errors that brought me here. Presumably the issue was namespaces and the fault was my own, especially if this isn't an issue anyone has brought up before. |
Beta Was this translation helpful? Give feedback.
-
I have a scene that I'm trying to serialize to XML. The scene contains Components that hold onto references to other components. I've made them hold onto Component IDs (unsigned int), thus I need to serialize a set. I figured the easiest way would be to use JSON, and not being able to find any way to extend the type conversions on Variant without editing Variant.h/Variant.cpp I set out to edit them.
I have these simple converter files that allow nlohmann's json to work with EASTL's string and vector. If I put them into my own new project, then they work great. If I put them into the existing Urho3D project, then they fail with a slew of template errors. The errors are the same as if the converter functions weren't found, so that's probably what's happening.
JSON.h
JSON.cpp
Within the Urho3D project, the fact that I have to_json and from_json in the nlohmann namespace means that the library can't find any other converters, so something as simple as nlohman::json j = std::string(); fails because it can't convert to std::string, but it suddenly can again if I change the namespace name. This didn't happen in my project - my converters being in the nlohmann namespace was perfectly fine and had no effect on the compiler's ability to find other converters.
It makes no sense to me that it works in one project but not another, unless there's something set in the project settings for Urho3D that is making this fail? I can't being to imagine what that is.
Beta Was this translation helpful? Give feedback.
All reactions