JSON Arrays In Java -


so i'm looking add lot of users group messaging app allows http post requests , i'm going try use file upload function read json i'm little confused how write in java:

{   "members": [     {       "nickname": "mom",       "user_id": "1234567890",       "guid": "guid-1"     },     {       "nickname": "dad",       "phone_number": "+1 2123001234",       "guid": "guid-2"     },     {       "nickname": "jane",       "email": "jane@example.com",       "guid": "guid-3"     }   ] } 

this exmaple of json file need write to, can explain how write in java? (it need nickname & phone_number fields, 2 per person) thanks!

edit 1: sorry, wasn't clear. need use java produce file these contents.

try try https://github.com/google/gson

http://www.studytrails.com/java/json/java-google-json-parse-json-to-java.jsp

example:

import com.google.gson.gson;  public class javatojsonandback {      public static void main(string[] args) {         albums albums = new albums();         albums.title = "free music archive - albums";         albums.message = "";         albums.total = "11259";         albums.total_pages = 2252;         albums.page = 1;         albums.limit = "5";         gsonbuilder builder = new gsonbuilder();         gson gson = builder.create();         system.out.println(gson.tojson(albums));      } }  how resulting json looks  {"title":"free music archive - albums","message":"","errors":[], "total":"11259","total_pages":2252,"page":1,"limit":"5"} 

Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -