Is there a way to use org.apache.sling.commons.json.JSONObject on Sightly ?
For example, if my Java class exposes a JSONObject :
public class Profile extends WCMUse { public JSONObject profileJson; public Profile() { super(); } @Override public void activate() throws Exception { /* { "user": { "surname": "Paul", "job": "developer" }, "age": 28 } */ String profileJsonString = "{\"user\":{\"surname\":\"Paul\",\"job\":\"developer\"},\"age\":28}"; profileJson = new JSONObject(profileJsonString); } public JSONObject getProfileJson(){ return profileJson; } }
Is there a way to access JSON fields on html files like that :
<div data-sly-unwrap data-sly-use.profile="${'com.test.Profile'}"></div> <h1>Profile</h1> <p>Surname : ${profile.profileJson.user.surname}</p> <p>Age : ${profile.profileJson.age}</p>