[ https://issues.apache.org/jira/browse/SLING-7934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16686926#comment-16686926 ]
Jason E Bailey commented on SLING-7934: --------------------------------------- I tend to have long conversations in my head and then come out with a statement that has a fully reasoned path that no one else follows. That's relevant here and I'm working on it. I wouldn't go with the .getJSONType() Because it's too specific to JSON and there's a part of me that bulks at doing a double lookup in a map, one to find the object and then another to get it's type. The problem comes back to is that a Map<String,Object> is really wider then what we use or need. From a resource perspective the value is either a String, Number, Boolean, or an Instant/Calendar object with array support. So my own stupid proposal would be, that if I had to change the ValueMap object I would rather change it to a Map<String,ResourceValue> which most people would never notice, because they are requesting a specific class type when they do their get. The change, however, would be really useful to anyone who needs to introspect the value type during processing. You could then do things such as ResourceValue.isArray() ResourceValue.getType() <- prefer an enum here ResourceValue.getOriginalType() ResourceValue.getValue() Though that could be implemented as part of existing interface as a supported type that internal conversions handle. meaning that it stays <Map,Object> but you could just do a .get(mykey, ResourceValue.class). Of course now I just typed all of this and I just had this moment of "woah" cause we could probably do .get(myKey,JsonValue.class) as well and then you would have to go through half the work that you otherwise would need to,. > Add the ability for a resource to adapt to a JSONObject > ------------------------------------------------------- > > Key: SLING-7934 > URL: https://issues.apache.org/jira/browse/SLING-7934 > Project: Sling > Issue Type: Improvement > Reporter: Jason E Bailey > Assignee: Jason E Bailey > Priority: Major > > There are multiple implementations all doing the same process of converting a > resource to a JSONObject. If it's that common we should just add the ability > to adapt the resource and centralize the implementation so that it's > consistent. -- This message was sent by Atlassian JIRA (v7.6.3#76005)