JAVA ドライバーを使用しており、ドキュメントの検索を実行しています。返されるドキュメントのタイプは Document です。
コードから、正しく出力される String type('name') を確認できます。時間の配列を文字列として表示することもできます。
私が探しているのは、値8になる時間[1] [2]を選択する配列から特定の要素を取得することです.
JSONObjectに変換せずに、Documentタイプでこの操作を直接実行しようとしています。
これは可能ですか?
{
"name": "Temp1", "hours": [ [ 0, 1, 2, 3, 4, 5 ], [ 6, 7, 8, 9, 10, 11 ],[ 12, 13, 14, 15 , 16, 17 ] ]
{
FindIterable<Document> iterable = collection.find(and(eq("day", day),eq("month", month),eq("year", year),eq("name", java.util.regex.Pattern.compile("Temp"))));
iterable.forEach(new Block<Document>() {
@Override
public void apply(final Document document) {
//System.out.println(document.toJson());
System.out.println("Name: "+document.getString("name"));
System.out.println("Hours[]: "+document.get("hours"));
}
}