jsonecode doesn't support complex doubles
23 次查看(过去 30 天)
显示 更早的评论
After a few error messages about encoding objects of class double, I figuered out that my highlevel structs had a field that contianed complex doubles, and therefore couldn't be encoded. So, I was wondering:
Is there a particular reason that complex doubles aren't supported by jsonecode?
If the reason isn't a lack of general consenus on default encoding of complex doubles in JSON, what is the convention?
Thanks,
0 个评论
采纳的回答
Ive J
2022-2-22
Here says:
"JSON has no standard way to represent complex numbers, so there is no way to test for them in JSON Schema."
Here also, you'll find more:
You have two (maybe more?) options:
x.a = 1 + 2i;
% 1st
mps.json.encode(x)
% 2nd
y = x;
y.a = string(y.a);
jsonencode(y)
% error
jsonencode(x)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 JSON Format 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!