Hi,
I am trying to access JSONObject in sightly html,but the data is not displayed.
Below is the sightly java file,where "result" variable is holding JSON string.
public class TestSightly extends WCMUse {
public String result;
public JSONObject jsonObject;
@Override
public void activate() throws Exception {
TestLocation testLocation = new TestLocation();
result = testLocation.testMessage();
jsonObject = new JSONObject(result);
}
public String getResult(){
return result;
}
public JSONObject getJsonObject(){
return jsonObject;
}
}
HTML File:
<div data-sly-include="/libs/wcm/core/components/init/init.jsp"></div>
<div data-sly-use.model="${'com.test.core.models.TestSightly'}">
<div>${model.result}</div>
<div>${model.jsonObject}</div>
</div>
With the above "model.result" is displaying the string data(json formatted data),but "model.jsonObject" is displaying nothing.
Thanks & Regards
swati
Solved! Go to Solution.