0

I am trying to send a JSON string along with the url ass http get using angular's $http service but somehow the curly braces are being removes when the request is sent because of may be angular's URI encode function is not working correctly, is there any work around for this? the samlpe would be if I send

http://someurl.com?a={"a":"b"} 

it is sent to server as

http://someurl.com?a="a":"b" 

I dont know whats wrong with Angular.

2
  • Show your actual code. I suspect you'll have to override paramSerializer Commented Jul 8, 2015 at 23:41
  • 4
    (1) Try JSON.stringify() (2) GET requests shouldn't be used like that. You should only need to send minimal, specific information as query parameters, not a full JS object. (3) Use a POST request for sending data to the server. Commented Jul 8, 2015 at 23:42

2 Answers 2

1

Use JSON.stringify to convert your url object into a JSON text. Then use encodeURIComponent(JSON_text) to encode the url.

Sign up to request clarification or add additional context in comments.

Comments

0

It is to do with URI encoding.

Take a look at the following question for your answer:

How to escape a JSON string to have it in a URL?

;)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.