Jackson JSON Processor
  1. Jackson JSON Processor
  2. JACKSON-610

Add readValue methods to ObjectReader to match methods in ObjectMapper

    Details

    • Type: New Feature New Feature
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      ObjectMapper provides about 30 different readValue methods, but ObjectReader currently has far fewer. Given an ObjectReader instance, an initial call to withType could be made before calling readValue, and thus provide more or all of the readValue alternatives available to ObjectMapper, but this would incur the cost of new ObjectReater
      instance creation every time.

      ObjectReader should be enhanced to add the rest of the ObjectMapper readValue counterparts, so as to provide a more complete immutable, thread-safe JSON reader API.

      (Perhaps the readValues methods in ObjectReader should be similarly increased to allow per-call target type specification.)

        Activity

        Hide
        Tatu Saloranta added a comment -

        Ok. I will need to think about all ramifications – as long as this does not lead to permutational explosion of new methods, and simplifies usage, new methods shoudl be added.

        Show
        Tatu Saloranta added a comment - Ok. I will need to think about all ramifications – as long as this does not lead to permutational explosion of new methods, and simplifies usage, new methods shoudl be added.
        Hide
        Programmer Bruce added a comment -

        I see now that _valueType is part of an ObjectReader's state (as are other things I didn't expect would be). So, the calls to readValue providing the target type still construct a new ObjectReader instance every time.

        For limited-resources platforms like Android, this might be an area to optimize to allow ObjectReader reuse for different target types. (Of course, actual testing should point to the performance bottlenecks, not guesswork.)

        Show
        Programmer Bruce added a comment - I see now that _valueType is part of an ObjectReader's state (as are other things I didn't expect would be). So, the calls to readValue providing the target type still construct a new ObjectReader instance every time. For limited-resources platforms like Android, this might be an area to optimize to allow ObjectReader reuse for different target types. (Of course, actual testing should point to the performance bottlenecks, not guesswork.)
        Hide
        Tatu Saloranta added a comment -

        Right, and the main benefit of it being part of state is just to reduce number of permutations needed; since there isn't much that can be done to input sources, unless one wants to add yet another abstraction to hide input source (which often leads to inconvenient non-abstractions like javax.xml.transform.Source).

        I agree in that construction of reader instances should not be a major problem even on Android unless tests show otherwise.

        Show
        Tatu Saloranta added a comment - Right, and the main benefit of it being part of state is just to reduce number of permutations needed; since there isn't much that can be done to input sources, unless one wants to add yet another abstraction to hide input source (which often leads to inconvenient non-abstractions like javax.xml.transform.Source). I agree in that construction of reader instances should not be a major problem even on Android unless tests show otherwise.
        Hide
        Tatu Saloranta added a comment -

        At this point I think I'd need to know suggested new methods to add, if any. Will keep this open, but not in-progress.

        Show
        Tatu Saloranta added a comment - At this point I think I'd need to know suggested new methods to add, if any. Will keep this open, but not in-progress.
        Hide
        Tatu Saloranta added a comment -

        Since 2.0.0 has added a few methods, and refactored ObjectReader/-Writers heavily, I will close this particular entry. Improvement ideas can be added, but I think it is better to start from scratch, to have clear baseline for additions.

        Show
        Tatu Saloranta added a comment - Since 2.0.0 has added a few methods, and refactored ObjectReader/-Writers heavily, I will close this particular entry. Improvement ideas can be added, but I think it is better to start from scratch, to have clear baseline for additions.

          People

          • Assignee:
            Tatu Saloranta
            Reporter:
            Programmer Bruce
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: