0

There is a file named countries.go It imports package github.com/ant0ine/go-json-rest/rest.

referred code from

https://gowalker.org/github.com/ant0ine/go-json-rest#countries

Countries section:Demo of POST DELETE etc

When i try to use command curl -i -d '{"Code":"FR","Name":"France"}' http_URL

It gives

{ "Error": "invalid character '\'' looking for beginning of value" }

I have used the package given above .It seems the method in the request.go given as DecodeJsonPayload() ,which implements unmarshal() for JSON , have internal server error.

I am unable to correct that.Help appreciated

Priyanka
  • 59
  • 2
  • 10

1 Answers1

1

I managed to duplicate your problem with curl on Windows.

Use the following curl command instead:

curl -i -d "{\"Code\":\"FR\",\"Name\":\"France\"}" http_URL

A related SO question: How to send double quote in -d parameter for curl.exe?

Community
  • 1
  • 1
ANisus
  • 74,460
  • 29
  • 162
  • 158
  • That worked but i was wondering if Unmarshal method can not take care of that?? – Priyanka Apr 22 '14 at 18:15
  • 1
    No, it can't. Because curl would send `'{Code:FR,Name:France}'` (including the apostrophes) to the Go server. That is broken JSON and the json package requires valid json data. – ANisus Apr 22 '14 at 22:55