add arbitrary JSON to a marshaled bean [message #1821075] |
Wed, 05 February 2020 08:59 |
Ilya Basin 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
|
|
|
Powered by
FUDForum. Page generated in 0.02129 seconds