Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » add arbitrary JSON to a marshaled bean
add arbitrary JSON to a marshaled bean [message #1821075] Wed, 05 February 2020 08:59
Ilya Basin is currently offline Ilya BasinFriend
Messages: 25
Registered: October 2011
Junior Member
Hi.
I'm designing a REST interface for JDBC. The response should contain table rows:
{
    "metadata": [
        {
            "name": "column title 1",
            "sqlType": "VARCHAR",
            "width": 255
        },
        {
            "name": "column title 2",
            "sqlType": "VARCHAR",
            "width": 255
        }
    ],
    "rows": [
        {
            "column title 1": "val1",
            "column title 2": "val2"
        },
        {
            "column title 1": "val1",
            "column title 2": "val2"
        }
    ],
    "runDate": "1970-01-01T02:59:59+03:00",
    "startRow": 100,
    "totalRows": 102
}


For type safety I wanted to use JSON bindings for most standard properties: "metadata", "totalRows", etc. and use something else for properties with non-compliant or unknown names - the column titles. Is it possible? I tried to assign a javax.json.JsonObject , but it's marshaled just like a normal java.util.Map (with "entry", "key" and "value"). I had better luck with org.w3c.dom.Element , but it doesn't let me create tags containing whitespace or other special characters. So I had to name the columns "col1", "col2", etc.

My server is Glassfish with MOXyJsonProvider
Previous Topic:LocalDateTime is not mapped correctly
Next Topic:EclipseLink throws JPQLException on using SELECT ... AS in a constructor expression
Goto Forum:
  


Current Time: Mon Apr 29 08:06:05 GMT 2024

Powered by FUDForum. Page generated in 0.04398 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top