How to convert a BasicDBList or BasicDBOject

2 ビュー (過去 30 日間)
KNC
KNC 2017 年 4 月 1 日
回答済み: Jayaram Theegala 2017 年 4 月 5 日
Hi,
i have a cell array from a MongoDB Json that I would like to convert to a matrix or vektor. The problem is that some of those cells are a "BasicDBList" or "BasicDBObject" containing multiple cells from the original Json. Is there a possibility to convert "BasicDBList"/"BasicDBObject" to double or a string array?
Thanks in advance

回答 (1 件)

Jayaram Theegala
Jayaram Theegala 2017 年 4 月 5 日
You can import the necessary MongoDB jars to MATLAB and then call the "toString" method of "BasicDBObject"/"BasicDBList", by doing this you can get the result in Java String type. Then you can convert the Java String to MATLAB char array as shown below:
str = java.lang.String('hello');
res = str.toCharArray'
If you want to convert the Java String to MATLAB string type, you can do it as shown below:
str = java.lang.String('hello');
res = string(str);
Please note that above shown conversion does not work on MATLAB R2016b and earlier versions. I hope this helps!

カテゴリ

Help Center および File ExchangeJSON Format についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by