I'm implementing Resource.put(), and I want to standardize on JSON as
my data representation language.

This resource is a User object called 'u', that contains one main
field, a Set of Integers called "tags".

Can someone let me know if I'm doing this right, and in the idiomatic
manner - or if I should be doing this a different way:

        @Override
        public void put(Representation entity) {
                try {
                        JSONObject nu = new 
JsonRepresentation(entity).toJsonObject();
                        JSONArray jStags = nu.getJSONArray("tags");
                        Set<User> tags = new HashSet<User>();
                        for (int x=0; x<jStags.length(); x++) {
                                tags.add(cf.users.get(jStags.getInt(x)));
                        }
                        u.setTags(tags);
                } catch (Exception e) {
                        log.error("Error parsing JSON while modifying a user", 
e);
                        
this.getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST,
e.getMessage());
                        return;
                }
        }

Can anyone give me some advice on how I should document this for
client writers (who will probably be using languages other than Java)?

Many thanks,

Ian.

-- 
Email: [EMAIL PROTECTED]
Cell: +1 512 422 3588
Skype: sanity

Reply via email to