You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been using this library quite a bit but am encountering one minor issue when using the dump() routine. I understand that the default std::map<StringType, basic_json> ordering used for iteratiors is lexicographical and that this is the ordering used for output in dump(). This is a direct result of std::less being used for the comparison functor as part of the ObjectType template parameter list.
Ideally, it would be nice to have a KeyType template parameter which complies with the default constructor for StringType but otherwise only needs to implement the operator<() as required for std::map.
Ideally i'd like my "KeyType" just to be as follows:
struct OrderedKey
{
std::string keyName;
unsigned int keyOrder;
};
comparison and "toString" operators would be defined for this custom key as well.
My question: Is it possible that this could be a feature in the foreseeable future? Or am I over thinking this? Essentially i just want to be able to define the order in which my keys are printed in dump() without rewriting the dump command.
Thanks.
The text was updated successfully, but these errors were encountered:
You may want to check the last bullet point of https://github.com/nlohmann/json#notes: you may pass a different type for the objects to achieve a different ordering in the objects.
I've been using this library quite a bit but am encountering one minor issue when using the dump() routine. I understand that the default std::map<StringType, basic_json> ordering used for iteratiors is lexicographical and that this is the ordering used for output in dump(). This is a direct result of std::less being used for the comparison functor as part of the ObjectType template parameter list.
Ideally, it would be nice to have a KeyType template parameter which complies with the default constructor for StringType but otherwise only needs to implement the operator<() as required for std::map.
Ideally i'd like my "KeyType" just to be as follows:
struct OrderedKey
{
std::string keyName;
unsigned int keyOrder;
};
comparison and "toString" operators would be defined for this custom key as well.
My question: Is it possible that this could be a feature in the foreseeable future? Or am I over thinking this? Essentially i just want to be able to define the order in which my keys are printed in dump() without rewriting the dump command.
Thanks.
The text was updated successfully, but these errors were encountered: