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

JsonMapper.ToJson("test\n\r"); throws Exception #102

Open
digitalpbk opened this issue Nov 30, 2018 · 2 comments
Open

JsonMapper.ToJson("test\n\r"); throws Exception #102

digitalpbk opened this issue Nov 30, 2018 · 2 comments

Comments

@digitalpbk
Copy link

JsonMapper.ToJson("test\n\r");

Expected Result: LitJson should be able to handle plain string encoding
Actual Result: Throws exception JsonException: Can't add a value here

@phamduylong
Copy link

Seems to be a real issue. Barely came across anyone who would do something like:

JsonMapper.ToJson(13);

But 13 is a valid JSON. I'll see what can I do with this.

@phamduylong
Copy link

phamduylong commented Nov 12, 2024

@devlead any plan to fix this? JSON specs state that string, numbers and boolean values are all valid JSON. I assume something like this in JsonMapper class could do the trick, but not the cleanest imo.

public static JsonData ToObject(int json) {
  return json.ToString();
}

public static JsonData ToObject(float json) {
  return json.ToString();
}

public static JsonData ToObject(double json) {
  return json.ToString();
}

public static JsonData ToObject(bool json) {
  return json.ToString();
}

public static JsonData ToObject(long json) {
  return json.ToString();
}

public static JsonData ToObject(byte json) {
  return json.ToString();
}

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