Results 1 to 6 of 6

Thread: No values displayed when NodeEntity object is converted to JSON with Jackson

Hybrid View

  1. #1
    Join Date
    Aug 2009
    Posts
    5

    Default No values displayed when NodeEntity object is converted to JSON with Jackson

    Hi Guys,

    I've been searching for days but only found this thread -> http://forum.springsource.org/showth...N-with-Jackson w/c didn't helped me at all.

    The issue is that, no values displayed when nodeentity from db is converted to json. Please see the attached project.
    Attached Files Attached Files

  2. #2
    Join Date
    May 2012
    Posts
    107

    Default

    ramirezag,

    I made a couple of changes to your pom, and `mvn clean test` is successful:

    Code:
            <repository>
                <id>neo</id>
                <name>neo</name>
                <url>http://m2.neo4j.org</url>
            </repository>
    ...
            <neo4j.version>1.8.RC1</neo4j.version>
            <spring.data.neo4j.version>2.1.0.RC4</spring.data.neo4j.version>
    Not sure what the problem was, but if we do not see it again that fine

    Regards,

    Lasse

  3. #3
    Join Date
    Aug 2009
    Posts
    5

    Default

    Thanks for these changes and sorry for the confusion. The issue is that, if you get User object
    Code:
    User result1 = userService.findByUid(user1.getUid());
    then deserialize result1 object
    Code:
    mapper.writerWithDefaultPrettyPrinter().writeValueAsString(user)
    username, password, email properties have no value.

    I uploaded the revised project here -> http://github.com/ramirezag/sdn-jack...on-problem.git. UserServiceImplTest will now fail in that project.

    Thanks

  4. #4
    Join Date
    Aug 2009
    Posts
    5

    Default

    Hi Guys,

    Can someone help me on this? I'm really clueless why domains fetched from db have problems when converted to json. If I simply instantiate a domain or object and then set the object's properties then convert it to json, I could see values of the properties.

  5. #5
    Join Date
    Jan 2011
    Location
    Dresden, Germany
    Posts
    525

    Default

    Hi,

    in the aspectj mapping mode your field access (within your class) is intercepted to be dynamically redirected to the neo4j store. So if anyone accesses the fields with reflection they won't contain any values. Try to serialize the bean getters instead.

    Can you try to use these Json annotations :

    Code:
    @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE, getterVisibility = JsonAutoDetect.Visibility.PUBLIC_ONLY)
    @JsonIgnoreProperties(value = {"persistentState","entityState","template","nodeId"})

  6. #6
    Join Date
    Aug 2009
    Posts
    5

    Default

    Wohooo. It worked. Thank you so much Michael

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •