Jump to content
  • JsonDataSource shouldn't attempt to convert value if there's no need to


    sebastien-jaspersoft
    Assigned User narcism
    CategoryBug report
    PriorityNormal
    ReproducibilityAlways
    ResolutionNo Change Required
    SeverityMinor
    StatusClosed
    Versionv6.4.0

    JsonDataSource does not allow to retrieve a field as eg. a JsonNode, which can be very usefull if your json has nested object.

    This is due to getFieldValue attempting to convert value even if there's no need to. Line 228 should be changed to if(selectObject != null && valueClass.isAssignableFrom(selectedObject.getClass())

     

    Steps to reproduce

     

    Create a json file with nested content, eg. [ { "customer": { "id: 38 } } ]

    Create a report with a field customer, of class com.fasterxml.jackson.databind.node.ObjectNode

    Run report => fails with Caused by: net.sf.jasperreports.engine.JRException: Field "customer" is of class com.fasterxml.jackson.databind.node.ObjectNode and can not be converted.

     

    Modify the field as java.lang.Object => report works and you can use the field as an ObjectNode by casting it everywhere you need it (kind of boring)



    User Feedback

    Recommended Comments

    Changed Status from Acknowledged to Feedback Requested

    Changed Assigned User from - to @narcism


    Do you have a specific use case where you really need the underlying com.fasterxml.jackson.databind.JsonNode implementation to work with?Your described use case could be easily solved with the following query and field declarations: customer id
    Link to comment
    Share on other sites

    Sorry for the lack of answer.

     

    This mean that you'll have to alias every single field… this is rather boring especially with deep objects tree.

     

    OTOH I can find any use case where the exception is a good thing

     

    Regards

    Link to comment
    Share on other sites



    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

×
×
  • Create New...