I'm using the nlohmann::json library to serialize/deserialize elements in json
.
Here's how I serialize a C++
array of double:
double mLengths[gMaxNumPoints] = { 1.0, 2.0, 3.0, 4.0, 5.0 };
...
nlohmann::json jsonEnvelope;
jsonEnvelope["lengths"] = envelope.mLengths;
Which produce:
"lengths":[
1.0,
2.0,
3.0,
4.0,
5.0
]
But now, how can I deserialize back to mLengths
? Tried with:
mLengths = jsonData["envelope"]["lengths"];
But it says expression must be a modifiable lvalue
. How can I restore back the array?