java - Play framework how can I put a name to my Json set -


i learning play framework(java) 2.40 , going through json examples , wondering how can put name json set? have..

    public static result jsontry() {      objectnode result = json.newobject();       result.put("1","one");     result.put("2","two");     return ok(result); } 

which returns ["1":"one","2":"two"] trying name set "numbers" . jsonobject , jsonarray deprecated in play framework 2.40 can not use suggestions great. got code above documentation https://www.playframework.com/documentation/2.0/javajsonrequests

jsonnodefactory nodefactory = jsonnodefactory.instance; objectnode responsenode = nodefactory.objectnode(); objectnode result = json.newobject();     result.put("1","one");     result.put("2","two"); responsenode.put("numbers", result);  return ok(responsenode); 

try out. or can use simple java hashmap. set data , return map json.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -