-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed as not planned
Labels
status: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancementA general enhancement
Description
Rasheed Amir opened DATAMONGO-1651 and commented
We have some entities which are extendable. And in order to make them extedable we have a field of type com.fasterxml.jackson.databind.node.JsonNode
in them; so, that we can store key & value sort of data in it and then we can do searching on base of it as well. By default it serializes a JsonNode
like as following:
{
"qXiPdBVWnFqgSTaTXEiqrgjPp" : {
"_children" : {
"7c6b5721-744e-44ef-94c2-cdcd16dfdb6c" : {
"_value" : "cb3dfac3-0552-4d48-9e06-20bb688330ff",
"_class" : "com.fasterxml.jackson.databind.node.TextNode"
},
"47d32e01-a274-4995-b22c-d032fc39ee2b" : {
"_children" : [
{
"_value" : "7e97f0f0-2b14-46e1-8998-95163f729371",
"_class" : "com.fasterxml.jackson.databind.node.TextNode"
},
{
"_value" : "74cd183a-68a3-483f-88dc-ca0d273d5744",
"_class" : "com.fasterxml.jackson.databind.node.TextNode"
},
{
"_value" : "0a897d65-c7c0-48ad-b0d5-a46d3a836397",
"_class" : "com.fasterxml.jackson.databind.node.TextNode"
}
],
"_nodeFactory" : {
"_cfgBigDecimalExact" : false
},
"_class" : "com.fasterxml.jackson.databind.node.ArrayNode"
},
"6fc3394b-d235-4467-8f60-b5c71c8fb4b9" : {
"_children" : {
"d989c804-7d6f-45b3-90d7-4f0d63964500" : {
"_value" : "17a4fcc6-f4c4-4680-989b-4640721033fe",
"_class" : "com.fasterxml.jackson.databind.node.TextNode"
},
"bcbc9540-1a33-47ec-af0a-9ba8de572323" : {
"_children" : [
{
"_value" : "2fee7cdf-ea40-4b95-a696-a8b7e1d9df8d",
"_class" : "com.fasterxml.jackson.databind.node.TextNode"
},
{
"_value" : "5359075e-475e-4987-bf24-ecd7d5b06756",
"_class" : "com.fasterxml.jackson.databind.node.TextNode"
},
{
"_value" : "4aea693b-a49c-4b9a-9505-376ea4daa622",
"_class" : "com.fasterxml.jackson.databind.node.TextNode"
}
],
"_nodeFactory" : {
"_cfgBigDecimalExact" : false
},
"_class" : "com.fasterxml.jackson.databind.node.ArrayNode"
}
},
"_nodeFactory" : {
"_cfgBigDecimalExact" : false
},
"_class" : "com.fasterxml.jackson.databind.node.ObjectNode"
}
},
"_nodeFactory" : {
"_cfgBigDecimalExact" : false
},
"_class" : "com.fasterxml.jackson.databind.node.ObjectNode"
},
…
}
And it has two issues:
- its not searchable
- deserialization doesn't work; and when you try to read back you get this error
org.springframework.data.mapping.model.MappingInstantiationException: Failed to instantiate com.fasterxml.jackson.databind.node.ObjectNode using constructor NO_CONSTRUCTOR with arguments
I would like it to serialize customdata like following:
{
"customData" : {
"acctest_boolFalse" : false,
"acctest_numberList" : [
1.0,
1.2,
3.0
],
"acctest_stringList" : [
"entry1",
"entry2"
],
"acctest_boolTrue" : true,
"acctest_int" : {
"subStringList" : [
"entry1",
"entry2"
]
},
"acctest_boolList" : [
true,
false,
true
],
"acctest_objList" : [
{
"subStringList" : [
"entry1",
"entry2"
]
},
{
"subBool" : true
}
],
"acctest_hej" : "seriesString",
"acctest_null" : null,
"acctest_decimal" : 1.12
}
}
One easy hack is to register a custom Converter ( e.g. convert to String) but that way searching doesn't work. I can create sample project if you need
1 votes, 4 watchers
Metadata
Metadata
Assignees
Labels
status: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancementA general enhancement