开发者

How to extract values from json request

Consider this is the sample request..

Now i have to post this.. and once details is added i want to check that correct details only added in the DB. I have extracted the value from DB.

I know that how to extract value from the response... Can any one help me on getting the value from the JSON request... Like i need to extract firstname,lastname,etc.,, can any one help me on this?

Request:

POST /MMNRS/1/consumer HTTP/1.1
Host: http://subdomain.example.com
Device-ID: 2b6f0cc904d137be2e1730235f5664094b831186
Client-Type: IPHONE
Client-Version: 1.0
User-Agent:开发者_运维问答 Tap/1.0 (iPhone; U; iOS 4.1; en_gb) 
Accept: application/json
X-Request-ID: 10002
{
    “consumerDetails”:
        {
            “title”:”Mr”,
            “firstName”:”John”,
            “lastName”: “Doe”,
            “dateOfBirth”:”12/05/1956”,
            “email”:”johndoe@gmail.com”,
            “encryptedPassword”:”XXXXYYYYZZZZ”,
            “acceptedTermsAndConditionsFlag”:true,
            “acceptedPromotionsAndOffersFlag” : true
            “versionNumber”: 0
        }
    “twk”: “XXYYZZVVSS”
    “passwordLength”: 7
    “encryptedConfirmPassword”:”XXXXYYYYZZZZ”,
    “confirmPasswordLength”: 7
    “confirmEmail”:”johndoe@gmail.com”,
    “securityQuestionAnswers” : 
        [
            {
                “securityQuestionId”    : 1001,
                “securityAnswer”    : “Rufus the Dog”
                “versionNumber”: 0
            },
            {
                “securityQuestionId”    : 1002,
                “securityAnswer”    : “Beethovan”
                “versionNumber”: 0
            }
        ],
}


The latest version of Groovy (1.8) comes with a built in JSON Parser/Builder

This link should help you

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜