Open muditskyfactor opened 6 years ago
Hi @muditskyfactor,
You can define rawData
as Map<String, String>
. It will create a JSON Object in MongoDB. Can you provide your sample data?
-Karthik
Thanks! Karthik,
Following is the sample json data that would come in the rawData field
{
"_id" : "4692c8fd-1ebf-4b0b-a9a4-d75e114fdabb",
"box_volume" : 11176.0,
"object_host_message" : [
"]C10259612850147114161000158"
],
"device_id" : 32,
"bar_codes" : {
"vcc" : "3",
"cc" : "3"
},
"object_gap_value" : 69.5199966430664,
"poly_unit" : "inch",
"object_id" : "70e7b35c-d6da-4fb8-8c0c-335c5ef56af4",
"real_volume" : 11154.0,
"object_conditions" : [
"PDFw9612",
"Shape",
"ValidWeight",
"ValidRead",
"LFT",
"ValidDim"
],
"angle" : -3.0,
"object_secondary_id" : 7154,
"position" : [
{
"x" : 0.0,
"y" : 41.2999992370605,
"z" : 2.6800000667572
},
{
"x" : 0.0500000007450581,
"y" : 30.4799995422363,
"z" : 2.6800000667572
},
{
"x" : 39.3800010681152,
"y" : 41.4799995422363,
"z" : 2.6800000667572
},
{
"x" : 39.4300003051758,
"y" : 30.6599998474121,
"z" : 2.6800000667572
}
],
"object_speed" : 544.489990234375,
"device_name" : "01",
"udf_fields" : {
"uds4" : "00",
"uds5" : "OK",
"uds2" : "<owe unit=\"lbs\">
-Mudit
Hi @muditskyfactor,
I am assuming you don't know the structure of the objects to be stored under rawData
field. So, you cant define its structure.
It's not convertible to Map<String, String> as JSON structure is complex (containing embedded objects, lists, etc).
Saving to JSON object is not possible as of now using Kundera.
Although, using native java driver, you can convert JSON string in Document
and store it.
Document myDoc = Document.parse(jsonString)
Anyways how will user define this need of conversion to JSON field in Entity Class. Any thoughts on this?
I am creating a simple Entity model with one string field that contains JSON. I want to store this as a JSON object/node and not as a string in mongodb
My Entity model is as below:
}
The rawData field will contain JSON as string. While the data is getting persisted in database. The rawData is saved as string form and not as a JSON document.
Please suggest.