Fabric: `fromDynamic`: Parsing vector type when source has no array
Summary: @public If some prop has `std::vector` type, it possible that on JS side we want to pass just one element of the array. And in this case we sometimes drop array initialization (`[]`) part, so instead of passing `[{x:1, y:1}]` we pass `{x:1, y:1}`. This diff adds support for that. Reviewed By: mdvacca Differential Revision: D8526572 fbshipit-source-id: 33d4369ac48cac3eb1c534f477d8259e76e0c547
This commit is contained in:
parent
f6aa5db0e4
commit
8ef539e0c2
|
@ -26,6 +26,13 @@ inline void fromDynamic(const folly::dynamic &value, std::string &result) { resu
|
|||
|
||||
template <typename T>
|
||||
inline void fromDynamic(const folly::dynamic &value, std::vector<T> &result) {
|
||||
if (!value.isArray()) {
|
||||
T itemResult;
|
||||
fromDynamic(value, itemResult);
|
||||
result = {itemResult};
|
||||
return;
|
||||
}
|
||||
|
||||
result.clear();
|
||||
T itemResult;
|
||||
for (auto &itemValue : value) {
|
||||
|
|
Loading…
Reference in New Issue