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

Unexpected type conversion #365

Closed
rpdprd opened this issue Sep 26, 2016 · 3 comments
Closed

Unexpected type conversion #365

rpdprd opened this issue Sep 26, 2016 · 3 comments

Comments

@rpdprd
Copy link

rpdprd commented Sep 26, 2016

Is there a way for the JSON document to be stored as is? For example, string "true" and string "42" are converted to boolean ant number respectively.

curl -H "Content-Type: application/json" -X POST -d '{"field1":"xyz","field2":"true","field3":"42","field4":"null"}' http://localhost:3000/example
{
  "field1": "xyz",
  "field2": true,
  "field3": 42,
  "field4": "null",
  "id": 1
}

While it may not be significant in javascript, the resulting document cannot be easily decoded to a map in Go (and maybe other languages) if the expected type is a string.

Thanks

@typicode
Copy link
Owner

typicode commented Oct 5, 2016

Hi @rpdprd,

Not right now, but it's something that I'm working on (next branch).

@typicode
Copy link
Owner

I've published v0.9.0-beta.2 which should improve this. Auto convert has been removed.

If you want, you can give it a try using npm install json-server@next.
README for v0.9.0 can be found in the next branch https://github.com/typicode/json-server/tree/next

Feedback is welcome :)

@typicode
Copy link
Owner

Should be good in v0.9.0

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