I have a JSON structure as given below, How to create this JSON Array structure programatically:

json srtucture

{ 
"Employee": 
    [ 
    { 
    "EmP325235": 
    { 
    "Name":"Rekha_S", 
    "firstName":"Rekha", 
    "phoneWork":"788908909", 
    "lastName":"S", 
    "namePrefix":"Miss", 
    "phoneMobile":"3347687878", 
    "phoneHome":"5768900909", 
    "Email":"" 
    }, 
    "Em252555": 
    { 
    "Name":"Roopa_N", 
    "firstName":"Roopa", 
    "phoneWork":"0471245367", 
    "lastName":"N", 
    "namePrefix":"", 
    "phoneMobile":"", 
    "phoneHome":"", 
    "Email":"" 
    } 
    } 
    ], 
    "User_Details": 
    { 
    "USER_ID":"7890", 
    "Number":"8585858585", 
    "Password":"Passwordsgs" 
    } 
    }
share|improve this question
Are you asking for recommendations for a JSON library for Java? There are lots at json.org – Stephen C Nov 2 '11 at 6:48

3 Answers

up vote 4 down vote accepted

this should provide with the examples you are looking for

http://code.google.com/p/json-simple/wiki/DecodingExamples

http://code.google.com/p/json-simple/wiki/EncodingExamples

json-simple home

share|improve this answer
how can we create array of array (json arary) – jennifer Nov 2 '11 at 6:55
may be this question has what you are looking for stackoverflow.com/questions/4467633/… – ashutosh raina Nov 2 '11 at 6:58
Thanks ashutosh raina – jennifer Nov 2 '11 at 10:04

I'd probably use the GSON library which will marshall Java objects.

There's an array example to get you started, as well as a ton of others in the user guide.

share|improve this answer

XStream provides a very convenient way to transform JSON to JAVA and back. Its annotation based and does the conversion job pretty well. Check XStream

share|improve this answer

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.