Construct JSON with explicit key order.
We are at liberty to order our JSON any way we like (by spec) and we can improve readability a lot by doing so. By default, this JSON library uses an unordered map for objects, but it's relatively easy to switch in a FiFo map that keeps track of the insertion order.
This commit is contained in:
parent
c70ded31d5
commit
423458a841
|
@ -54,6 +54,16 @@ set(MATHFU_INCLUDE_DIRS
|
|||
"${CMAKE_BINARY_DIR}/mathfu/src/MathFu/include/"
|
||||
"${CMAKE_BINARY_DIR}/mathfu/src/MathFu/dependencies/vectorial/include")
|
||||
|
||||
# OrderedMap
|
||||
ExternalProject_Add(FiFoMap
|
||||
PREFIX fifo_map
|
||||
GIT_REPOSITORY https://github.com/nlohmann/fifo_map
|
||||
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E echo "Skipping FiFoMap configure step."
|
||||
BUILD_COMMAND ${CMAKE_COMMAND} -E echo "Skipping FiFoMap build step."
|
||||
INSTALL_COMMAND ${CMAKE_COMMAND} -E echo "Skipping FiFoMap install step."
|
||||
)
|
||||
set(FIFO_MAP_INCLUDE_DIR "${CMAKE_BINARY_DIR}/fifo_map/src/FiFoMap/src")
|
||||
|
||||
# JSON
|
||||
ExternalProject_Add(Json
|
||||
PREFIX json
|
||||
|
@ -138,6 +148,7 @@ add_executable(FBX2glTF ${SOURCE_FILES})
|
|||
add_dependencies(FBX2glTF
|
||||
Draco
|
||||
MathFu
|
||||
FiFoMap
|
||||
Json
|
||||
CxxOpts
|
||||
CPPCodec
|
||||
|
@ -167,6 +178,7 @@ target_include_directories(FBX2glTF PUBLIC
|
|||
${FBXSDK_INCLUDE_DIR}
|
||||
${DRACO_INCLUDE_DIR}
|
||||
${MATHFU_INCLUDE_DIRS}
|
||||
${FIFO_MAP_INCLUDE_DIR}
|
||||
${JSON_INCLUDE_DIR}
|
||||
${CXXOPTS_INCLUDE_DIR}
|
||||
${CPPCODEC_INCLUDE_DIR}
|
||||
|
|
|
@ -18,7 +18,12 @@
|
|||
#include <draco/compression/encode.h>
|
||||
|
||||
#include <json.hpp>
|
||||
using json = nlohmann::json;
|
||||
#include <fifo_map.hpp>
|
||||
|
||||
template<class K, class V, class ignore, class A>
|
||||
using workaround_fifo_map = nlohmann::fifo_map<K, V, nlohmann::fifo_map_compare<K>, A>;
|
||||
|
||||
using json = nlohmann::basic_json<workaround_fifo_map>;
|
||||
|
||||
#include "FBX2glTF.h"
|
||||
#include "RawModel.h"
|
||||
|
|
Loading…
Reference in New Issue