Skip to content

Performance improvement for POJO conversion into JSONObject #844

Closed

Description

@seppl831

Hi,

when converting a POJO into a JSONObject we are experiencing performance degradations due to the annotation search in superclasses of the POJO.

The method getAnnotationDepth in JSONObject should not search methods in superclasses if the superclass is java.lang.Object. At the moment the search is stopped only if the superclass is null, i.e. the Object-class is searched also. This leads to recurring NoSuchMethodExceptions, which are catched but unnecessary.

A short performance test for a big HashMap (only POJOs) being converted to a JSONObject showed 900ms duration with the actual code. When avoiding the search in java.lang.Object the conversion of the same map takes only less than 70ms on the same system/environment.

Activity

  1. stleary commented on Dec 29, 2023

    @stleary
    Owner

    Closing due to issue is addressed in an approved pull request.

  2. ghost closed this as completedon Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions