php - how to include one JSON into another JSON? -


my first json is: come java url, here using php, in php iam calling java url.

{     "categoryid":"painting",     "subcategoryid":"residential",     "alternatives":    [1,2,3,4,5],     "criterias":["price","quantity","yom","company"],     "answerss":[["1000","12343","4543","","4645646"],["12","23","34","","45"],["2014","","2000","1990","2005"],["xyz","","abc","jkl","mno"]]   }   

my second json is: iam generating using jquery.

{"criterias":"location"}   

how can include second json first json criterias.

you need convert first json string object , add new property it.

if java, can use google's gson library

gson gson = new gson(); jsonobject jsonobj = gson.fromjson (jsonstr, jsonelement.class).getasjsonobject(); jsonobj.add("criterias", "location"); 

if javascript,

var jobj = json.parse(jsonstring); jobj.criterias = "location";  //jobj.newitem = "newvalue"; 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -