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

Trim spaces! OMG! #73

Closed
isergey opened this issue Nov 27, 2012 · 1 comment
Closed

Trim spaces! OMG! #73

isergey opened this issue Nov 27, 2012 · 1 comment

Comments

@isergey
Copy link

isergey commented Nov 27, 2012

" " != ""
May be remove this trim, because in terms of XML is wrong. There is no way to restore the information, encoded in the spaces!

public Object nextContent() throws JSONException {
    char c;
    StringBuffer sb;
    c = next();
    /*
     * do { c = next(); } while
     * (Character.isWhitespace(c));
     */
    if (c == 0) {
        return null;
    }
    if (c == '<') {
        return XML.LT;
    }
    sb = new StringBuffer();
    for (;;) {
        if (c == '<' || c == 0) {
            back();
            //return sb.toString().trim();
            return sb.toString();
        }
        if (c == '&') {
            sb.append(nextEntity(c));
        } else {
            sb.append(c);
        }
        c = next();
    }
}

Also, in transformation JSONObject -> Xml.toString - > Xml.toJSONObject lost leading zeros.
It would be logical not to parse a string containing a number as numerical types, and provide the user to get them as numerical types.

@douglascrockford
Copy link
Contributor

It works for me in its current form. You have the source. You can make it work as you like.

BGehrels pushed a commit to BGehrels/JSON-java that referenced this issue Apr 29, 2020
Updates tests for better error handling changes
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