Home > DeveloperSection > Forums > Proper Mapping for dynamic fields
Hank Greenberg
Hank Greenberg

Total Post:12

Points:84
Posted on    July-08-2013 8:46 AM

 JSON JSON 
Ratings:


 1 Reply(s)
 998  View(s)
Rate this:
Hi Expert!

I have the following document structure:

{
  "some_field": "some_data",
  "entries": {
    {"id": "some_id", "type": "some_type", "value": "some_value"},
    {"id": "another_id", "type": "another_type", "value": {"foo": 1, "bar": "two"}
  }
}

So I would like to map entries based on the "type" field. Which mapping type or flag should I use? Or maybe I need to change my doc structure?



AVADHESH PATEL

Total Post:604

Points:4228
Posted on    July-08-2013 8:59 AM

Hi Hank!

I think you should use array with "'[' ']'" you can check your json using this website

{
   "some_field":"some_data",
   "entries":[{
         "id":"some_id",
         "type":"some_type",
         "value":"some_value"
      },
      {
         "id":"another_id",
         "type":"another_type",
         "value":{
            "foo":1,
            "bar":"two"
         }
      }]
}

Don't want to miss updates? Please click the below button!

Follow MindStick