java - How to convert Json string with key-value pair into string with only value -
i converted pojo data json string way,
gson gson = new gsonbuilder().disablehtmlescaping().create(); string json=gson.tojson(user);
i got json string not format need, got
json = {"userid":300,"username":"asd","password":"s","enabled":1}
so, want convert json string key-value pair below ,
{"userid":300,"username":"asd","password":"s","enabled":1}
into json string value (without key) below
[300,"asd","s",1]
you whack properties of user
list<object>
, json that.
this mean gson made json array out of list
, want.
as doesn't seem make sense use case have bit of hardcoding - don't think gson can you:
final list<object> props = new linkedlist<>(); props.add(user.getid()); props.add(user.getusername()); //etc final string json=gson.tojson(props);
Comments
Post a Comment