@@ -161,13 +161,13 @@ struct Pose2D {
161
161
}
162
162
```
163
163
164
- You will need to include **behaviortree_cpp/json_export.h** and follow the
165
- following instructions, based on your BT.CPP version.
164
+ You will need to include **behaviortree_cpp/json_export.h** and follow these
165
+ instructions, based on your BT.CPP version.
166
166
167
167
168
168
### Version 4.3.5 or earlier
169
169
170
- Implement this function, being carefull about using the namespace `nlohmann`:
170
+ Implement the function `nlohmann::to_json() `:
171
171
172
172
```cpp
173
173
namespace nlohmann {
@@ -179,16 +179,18 @@ namespace nlohmann {
179
179
}
180
180
```
181
181
182
- Then, registered the function adding this to you ** main** :
182
+ Then, register the function adding this to your ** main** :
183
183
184
184
``` cpp
185
185
BT::JsonExporter::get ().addConverter<Pose2D>();
186
186
```
187
187
188
188
### Version 4.3.6 or later
189
189
190
- The implementation of the "to_json" function has no limitations in terms of name and namespace,
191
- as long it can be casted to ` std::function<void(nlohmann::json&, const Pose2D&)> ` , for instance:
190
+ The implementation of the "to_json" function has can have any name or namespace,
191
+ but it must conform to the signature ` void(nlohmann::json&, const T&) ` .
192
+
193
+ For instance:
192
194
193
195
``` cpp
194
196
void PoseToJson (nlohmann::json& dest, const Pose2D& pose) {
@@ -198,7 +200,8 @@ void PoseToJson(nlohmann::json& dest, const Pose2D& pose) {
198
200
}
199
201
```
200
202
201
- And registered the function adding this to you **main**:
203
+ Register the function adding this to your **main**:
204
+
202
205
```cpp
203
206
BT::RegisterJsonDefinition<Pose2D>(PoseToJson);
204
207
```
0 commit comments