GithubHelp home page GithubHelp logo

parsers-in-java's People

Contributors

jjenkov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

parsers-in-java's Issues

Input should not be taken as `java.lang.String`

If I did not misread test sources, input is taken as java.lang.String.
I think this is incorrect and should be changed to a byte source.

This is fundamentally wrong choice, given that input for parsing practically always comes as a byte source (stream, ByteBuffer, byte array). And although the next step for textual data formats like JSON and XML typically is decoding into characters, efficiency of doing so varies a lot. Same is true for ability to stream (or not) from arbitrary length content; but I guess that may be ignored for now, and just note that certain optimizations are only possible if the exact length of input is known.

This is especially true for libraries that do allow either more efficient char decoding than what JDK offers (for XML that'd be Woodstox at least), or combine parts of decoding, validation and lexing straight from byte sources (for JSON that's FastJSON and Jackson at least).

For better take on performance comparisons in this respect, you could consider checking out:

https://github.com/eishay/jvm-serializers

which uses byte[] as the common input source: libraries that expect character-based sources can then construct either Strings or Readers.

JsonParser have error in parse()

In parse() method you assert that the json stream to parse is always an object, but the specification of the format says that json stream can be an array or an object.

Turn DataBuffer into an interface, have an impl that takes a String

I've tried to optimize things (smaller inlinable methods, switches instead of if/elseif, cached parser instances).

So far, the only thing that did performed better was turning DataCharBuffer into an interface, and add an implementation that wraps a String instead of a char array, thus saving an array copy.

This improved performance on big JSON messages of ~15%.

I'm still puzzled about your implementation being beaten by gson and json-smart on smaller messages. I suspect IndexBuffer's arrays allocation.

ArrayIndexOutOfBoundsException

Hi,

I wanted to give your JSON parser a spin after reading your post on InfoQ.

Getting an ArrayIndexOutOfBoundsException with the following JSON string:

{ "store": {
    "book": [ 
      { "category": "reference",
        "author": "Nigel Rees",
        "title": "Sayings of the Century",
        "price": 8.95
      },
      { "category": "fiction",
        "author": "Evelyn Waugh",
        "title": "Sword of Honour",
        "price": 12.99
      },
      { "category": "fiction",
        "author": "Herman Melville",
        "title": "Moby Dick",
        "isbn": "0-553-21311-3",
        "price": 8.99
      },
      { "category": "fiction",
        "author": "J. R. R. Tolkien",
        "title": "The Lord of the Rings",
        "isbn": "0-395-19395-8",
        "price": 22.99
      }
    ],
    "bicycle": {
      "color": "red",
      "price": 19.95
    }
  }
}

Full stacktrace:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 715
    at com.jenkov.parsers.json.JsonTokenizer.parseStringToken(JsonTokenizer.java:67)
    at com.jenkov.parsers.json.JsonTokenizer.parseToken(JsonTokenizer.java:56)
    at com.jenkov.parsers.json.JsonParser.parseObject(JsonParser.java:43)
    at com.jenkov.parsers.json.JsonParser.parseArray(JsonParser.java:77)
    at com.jenkov.parsers.json.JsonParser.parseObject(JsonParser.java:47)
    at com.jenkov.parsers.json.JsonParser.parse(JsonParser.java:22)

Regards,

Stéphane

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.