Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json parsing of response #12

Closed
asthanasid opened this issue Jan 12, 2014 · 2 comments
Closed

json parsing of response #12

asthanasid opened this issue Jan 12, 2014 · 2 comments

Comments

@asthanasid
Copy link

To perform JSON parsing of response, the code checks of "jsonctype":["application/json","application/json;charset=utf-8"], in response header.

Its failing for me becuase in my case. the rest endpoint returns content header as "application/json; charset=utf-8" (notice the space between encoding directive).

May be the better approach would be to split the string and look for "application/json"

@aacerox
Copy link
Owner

aacerox commented Jan 13, 2014

Hi

you can customize content type of the response by setting the parameter "mimetypes" in the options passed to client. in your case it would be:

var options ={  
    // customize mime types for json or xml connections 
    //(in your case with a space between type and charset)
    mimetypes:{
        json:["application/json","application/json; charset=utf-8"],
        xml:["application/xml","application/xml; charset=utf-8"]
    } 
};

Client client = new Client(options)

For more info on client options customization please see https://github.com/aacerox/node-rest-client#options-parameters

@aacerox aacerox closed this as completed Jan 13, 2014
@aacerox
Copy link
Owner

aacerox commented Jan 13, 2014

sorry this line

Client client = new Client(options)

is wrong, I wrote it in Java ;)

the correct way would be

var client = new Client(options)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants