diff --git a/CHANELOG.md b/CHANELOG.md index a254cf22..3ba47c13 100644 --- a/CHANELOG.md +++ b/CHANELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.82.1 (2025-07-10) + +- Add support for serialization and deserialization of std::vector for mujinjson. + ## 0.82.0 (2025-06-27) - Add targetTemplateSceneData in RegisterMinViableRegionInfo. diff --git a/CMakeLists.txt b/CMakeLists.txt index 116dc668..5eac7844 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ set( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE ) # make sure to change the version in docs/Makefile set (MUJINCLIENT_VERSION_MAJOR 0) set (MUJINCLIENT_VERSION_MINOR 82) -set (MUJINCLIENT_VERSION_PATCH 0) +set (MUJINCLIENT_VERSION_PATCH 1) set (MUJINCLIENT_VERSION ${MUJINCLIENT_VERSION_MAJOR}.${MUJINCLIENT_VERSION_MINOR}.${MUJINCLIENT_VERSION_PATCH}) set (MUJINCLIENT_SOVERSION ${MUJINCLIENT_VERSION_MAJOR}.${MUJINCLIENT_VERSION_MINOR}) set (CLIENT_SOVERSION ${MUJINCLIENT_VERSION_MAJOR}.${MUJINCLIENT_VERSION_MINOR}) diff --git a/include/mujincontrollerclient/mujinjson.h b/include/mujincontrollerclient/mujinjson.h index 3d23a788..973755cc 100644 --- a/include/mujincontrollerclient/mujinjson.h +++ b/include/mujincontrollerclient/mujinjson.h @@ -511,6 +511,17 @@ inline void LoadJsonValue(const rapidjson::GenericValue& v, } } +template , typename Allocator=rapidjson::MemoryPoolAllocator<> > +inline void LoadJsonValue(const rapidjson::GenericValue& v, std::vector::reference t) { + if (v.IsInt()) t = v.GetInt(); + else if (v.IsBool()) t = v.GetBool(); + else if (v.IsString()) { + t = LexicalCast(v.GetString(), "Bool"); + } else { + throw MujinJSONException("Cannot convert json type " + GetJsonString(v) + " to Bool"); + } +} + template, typename Encoding=rapidjson::UTF8<>, typename Allocator=rapidjson::MemoryPoolAllocator<> > inline void LoadJsonValue(const rapidjson::GenericValue& v, std::vector& t); @@ -715,6 +726,11 @@ inline void SaveJsonValue(rapidjson::GenericValue& v, const v.SetBool(t); } +template +inline void SaveJsonValue(rapidjson::GenericValue& v, const std::vector::reference t, Allocator2& alloc) { + v.SetBool(t); +} + template inline void SaveJsonValue(rapidjson::GenericValue& v, const int8_t& t, Allocator2& alloc) { v.SetInt(t);