public void extractLayoutKeys(Document mongoDoc) {
// Assuming the layout_name object is stored under the key "layout_name"
Document layoutNameObject = (Document) mongoDoc.get("layout_name");
if (layoutNameObject != null) {
Set<String> layoutKeys = layoutNameObject.keySet();
// Print or process the keys as needed
for (String key : layoutKeys) {
System.out.println("Key: " + key);
// Additional processing with each key
}
} else {
System.out.println("No 'layout_name' object found in the document.");
}
}
public static void main(String[] args) {
// Example usage
Document exampleDoc = new Document("CSPA", "67890")
.append("date", "2024-08-02")
.append("version", "v2")
.append("layout_name", new Document("Value", "7373737").append("Limit", "10000"));
LayoutKeySetExtractor extractor = new LayoutKeySetExtractor();
extractor.extractLayoutKeys(exampleDoc);
}
import org.bson.Document;
import java.util.Set;
public class LayoutKeySetExtractor {
}