Skip to content

Performance improvement for POJO conversion into JSONObject #844

@seppl831

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.

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