Hi All,
I have developed one static dropdown with node name tabs order, as shown below
I have written below JAVA code.
*********************** TabOrderModel JAVA Class ***********************
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
public class TabOrderModel {
String tabsOrderEnabled;
JsonArray tabsOrder;
public String getTabsOrderEnabled() {
return tabsOrderEnabled;
}
public void setTabsOrderEnabled(String tabsOrderEnabled) {
this.tabsOrderEnabled = tabsOrderEnabled;
}
public JsonArray getTabsOrder() {
return tabsOrder;
}
public void setTabsOrder(JsonArray tabsOrder) {
this.tabsOrder = tabsOrder;
}
@Override
public String toString() {
return "TabOrderModel [tabsOrderEnabled =" + tabsOrderEnabled + ", tabsOrder=" + tabsOrder + " ]";
}
}
****************************** JsonUtility JAVA *************************
private static void setTabOrderDetails(Node masterNode, ResourceResolver resourceResolver,
TabOrderModel tabOrderModel) throws RepositoryException {
if (masterNode.hasProperty(Constants.TABS_ORDER)) {
Property TabOrderProperty = masterNode.getProperty("tabsOrder");
//logger.info("values for TabOrderProperty ====== " + TabOrderProperty);//property=tabsOrder = [{"tabName":"community.about.value"}, {"tabName":"leadership.label.value"}, {"tabName":"community.about.value"},
multiValueTabOrder(resourceResolver, tabOrderModel, TabOrderProperty);
}
}
private static void multiValueTabOrder(ResourceResolver resourceResolver,
TabOrderModel tabOrderModel, Property TabOrderProperty) throws RepositoryException {
if (TabOrderProperty.isMultiple()) {
JsonArray array = new JsonArray();
JsonParser jsonParser = new JsonParser();
javax.jcr.Value[] values = TabOrderProperty.getValues();
for (javax.jcr.Value value : values) {
String jsonObj = value.getString();
logger.info("jsonObj123 for taborder ====== " + jsonObj);
array.add(jsonObj);
}
tabOrderModel.setTabsOrder(array);
}
}
But my JSON is coming below
My requirement is that ONLY tabName Value should come like below highlighted in red color but it is coming like above.
"tabsOrderSection": {
"tabsOrderEnabled": "true",
"tabsOrder": [
"community.about.value",
"leadership.label.value",
"community.about.value",
"leadership.label.value"
]
}
Can anybody please let me know how can I show only value of tabname inside JSON ?
Thanks