19
loading...
This website collects cookies to deliver better user experience
{
"total_rows": 1,
"bookmark": "g2wAAAABaANkAClkYmNvcmVAZGI3LmJtLWNjLXVzLXNvdXRoLTExLmNsb3VkYW50Lm5ldGwAAAACYhAAAABiH____2poAkY_8AAAAAAAAGEAag",
"rows": [
{
"fields": {
"url": "https://haralduebele.github.io/2019/02/17/blue-cloud-mirror-dont-open-the-doors/",
"customer": "your-blogs",
"title": "Blue Cloud Mirror — (Don’t) Open The Doors!",
"type": "articles",
"authorName": "Harald Uebele"
},
"id": "7a5f27ce3ef66f895cb666e46ce45e55"
}
]
}
rows[0].fields.authorName
rows[0].fields.title
rows[0].fields.url
// JSON
import javax.json.Json;
import javax.json.JsonObject;
import javax.json.JsonArray;
import javax.json.JsonReader;
// Need to the string input
import java.io.StringReader;
// Cloudant search response value
System.out.println("-->log: search_response.toString: " + search_response.toString());
// Create simple json object from response value
JsonReader jsonReader = Json.createReader(new StringReader(search_response.toString()));
JsonObject object = jsonReader.readObject();
jsonReader.close();
// Extract nested json array from simple json object
JsonArray rows = object.getJsonArray("rows");
System.out.println("-->log: rows: " + rows);
// Get the first json object entry in the json array
JsonObject row_object = rows.getJsonObject(0);
System.out.println("-->log: row_object: " + row_object);
// Extract the nested json object from the first json object entry
JsonObject fields = row_object.getJsonObject("fields");
System.out.println("-->log: fields: " + fields);
// Extract the relevant data from the nested json object
String url = fields.getString("url");
String authorName = fields.getString("authorName");
String title = fields.getString("title");
System.out.println("-->log: Author : " + authorName + " Title: " + " url: " + url);
-->log: search_response.toString: {
"total_rows": 1,
"bookmark": "g2wAAAABaANkAClkYmNvcmVAZGI3LmJtLWNjLXVzLXNvdXRoLTExLmNsb3VkYW50Lm5ldGwAAAACYhAAAABiH____2poAkY_8AAAAAAAAGEAag",
"rows": [
{
"fields": {
"url": "https://haralduebele.github.io/2019/02/17/blue-cloud-mirror-dont-open-the-doors/",
"customer": "your-blogs",
"title": "Blue Cloud Mirror — (Don’t) Open The Doors!",
"type": "articles",
"authorName": "Harald Uebele"
},
"id": "7a5f27ce3ef66f895cb666e46ce45e55"
}
]
}
-->log: rows: [{"fields":{"url":"https://haralduebele.github.io/2019/02/17/blue-cloud-mirror-dont-open-the-doors/","customer":"your-blogs","title":"Blue Cloud Mirror — (Don’t) Open The Doors!","type":"articles","authorName":"Harald Uebele"},"id":"7a5f27ce3ef66f895cb666e46ce45e55"}]
-->log: row_object: {"fields":{"url":"https://haralduebele.github.io/2019/02/17/blue-cloud-mirror-dont-open-the-doors/","customer":"your-blogs","title":"Blue Cloud Mirror — (Don’t) Open The Doors!","type":"articles","authorName":"Harald Uebele"},"id":"7a5f27ce3ef66f895cb666e46ce45e55"}
-->log: fields: {"url":"https://haralduebele.github.io/2019/02/17/blue-cloud-mirror-dont-open-the-doors/","customer":"your-blogs","title":"Blue Cloud Mirror — (Don’t) Open The Doors!","type":"articles","authorName":"Harald Uebele"}
-->log: Author : Harald Uebele Title: url: https://haralduebele.github.io/2019/02/17/blue-cloud-mirror-dont-open-the-doors/