#pragma once #include "CoreMinimal.h" #include "rapidjson/rapidjson.h" // rapidjson's DOM-style API #include "rapidjson/document.h" // rapidjson's DOM-style API #include "rapidjson/prettywriter.h" // for stringify JSON #include // 包含 GetParseError_En 函数 #include "MatureJsonEnums.h" // 包含 GetParseError_En 函数 #include #include #include #include namespace mature { template void print_type(); template class JsonChar { public: }; template<> class JsonChar : public rapidjson::UTF8 { public: }; template<> class JsonChar : public rapidjson::UTF16LE { public: }; template<> class JsonChar : public rapidjson::UTF16LE { public: }; template<> class JsonChar : public rapidjson::UTF32LE { public: }; typedef rapidjson::GenericStringRef StringRefType; typedef rapidjson::GenericDocument > Document; typedef rapidjson::GenericStringBuffer > StringBuffer; typedef rapidjson::Writer, JsonChar> Writer; typedef rapidjson::GenericValue > Value; typedef rapidjson::GenericArray Array; typedef rapidjson::GenericArray ConstArray; typedef rapidjson::GenericObject Object; typedef rapidjson::GenericObject ConstObject; typedef rapidjson::GenericMemberIterator, Document::AllocatorType> MemberIterator; typedef rapidjson::GenericMemberIterator, Document::AllocatorType> ConstMemberIterator; //using Allocator = Document::AllocatorType; typedef Document::AllocatorType Allocator; using Type = rapidjson::Type; //using Array = Value::Array; //using ConstArray = Value::ConstArray; //using Object = Value::Object; //using ConstObject = Value::ConstObject; template T GetNumber(const Value& ValueRef) { if (mature::Type::kNumberType!=ValueRef.GetType())return T(0); if (ValueRef.IsDouble())return T(ValueRef.GetDouble()); else if (ValueRef.IsInt64())return T(ValueRef.GetInt64()); else if (ValueRef.IsUint64())return T(ValueRef.GetUint64()); else if (ValueRef.IsInt())return T(ValueRef.GetInt()); else if (ValueRef.IsUint())return T(ValueRef.GetUint()); return T(0); } template bool GetNumberBool(const Value& ValueRef, T& value) { if (mature::Type::kNumberType != ValueRef.GetType())return false; if (ValueRef.IsDouble())value = T(ValueRef.GetDouble()); else if (ValueRef.IsInt64())value = T(ValueRef.GetInt64()); else if (ValueRef.IsUint64())value = T(ValueRef.GetUint64()); else if (ValueRef.IsInt())value = T(ValueRef.GetInt()); else if (ValueRef.IsUint())value = T(ValueRef.GetUint()); else return false; return false; } template T GetNumberArray(const unsigned int idx,const Array& ArrayRef) { if (ArrayRef.Size() < idx)return T(); return GetNumber(ArrayRef[idx]); } FString GetString(const Value& ValueRef); bool GetStringBool(const Value& ValueRef, FString& value); FString GetStringArray(const unsigned int idx, const Array& ArrayRef); }