atlasmap-attic / atlasmap-runtime

AtlasMap runtime engine and design time services
http://atlasmap.io
Other
3 stars 8 forks source link

Mapper takes first JSON property with the same name, ignoring JSON path #262

Closed zregvart closed 7 years ago

zregvart commented 7 years ago

I have a mapping that looks like:

mapping.json
{
  "AtlasMapping": {
    "jsonType": "io.atlasmap.v2.AtlasMapping",
    "dataSource": [
      {
        "jsonType": "io.atlasmap.json.v2.JsonDataSource",
        "id": "DOC.undefined.653275",
        "uri": "atlas:json:undefined",
        "dataSourceType": "SOURCE"
      },
      {
        "jsonType": "io.atlasmap.json.v2.JsonDataSource",
        "id": "add_lead_IN",
        "uri": "atlas:json:add_lead_IN",
        "dataSourceType": "TARGET",
        "template": null
      }
    ],
    "mappings": {
      "mapping": [
        {
          "jsonType": "io.atlasmap.v2.Mapping",
          "mappingType": "MAP",
          "inputField": [
            {
              "jsonType": "io.atlasmap.json.v2.JsonComplexType",
              "name": "name",
              "path": "/name",
              "fieldType": "STRING",
              "docId": "DOC.undefined.653275",
              "userCreated": false
            }
          ],
          "outputField": [
            {
              "jsonType": "io.atlasmap.json.v2.JsonComplexType",
              "name": "company",
              "path": "/company",
              "fieldType": "STRING",
              "docId": "add_lead_IN",
              "userCreated": false
            }
          ]
        },
        {
          "jsonType": "io.atlasmap.v2.Mapping",
          "mappingType": "MAP",
          "inputField": [
            {
              "jsonType": "io.atlasmap.json.v2.JsonComplexType",
              "name": "status",
              "path": "/status",
              "fieldType": "STRING",
              "docId": "DOC.undefined.653275",
              "userCreated": false
            }
          ],
          "outputField": [
            {
              "jsonType": "io.atlasmap.json.v2.JsonComplexType",
              "name": "lead_status",
              "path": "/lead_status",
              "fieldType": "STRING",
              "docId": "add_lead_IN",
              "userCreated": false
            }
          ]
        }
      ]
    },
    "name": "UI.252475",
    "lookupTables": {
      "lookupTable": []
    },
    "properties": {
      "property": []
    }
  }
}


When the input document looks like:

input.json
{
  "id": 1,
  "category": {
    "id": 0,
    "name": "string"
  },
  "name": "jack",
  "photoUrls": [
    "string"
  ],
  "tags": [
    {
      "id": 0,
      "name": "string"
    }
  ],
  "status": "available"
}


The output contains value "string" in company property, not "jack" as expected.

igarashitm commented 7 years ago

It must use get() instead of findValue() here to avoid jumping to the deeper node https://github.com/atlasmap/atlasmap-runtime/blob/d4e7b4b69964f7285ccd66a4c1b14c61f3675982/atlas-json-parent/atlas-json-core/src/main/java/io/atlasmap/json/core/JsonFieldReader.java#L38 https://github.com/atlasmap/atlasmap-runtime/blob/d4e7b4b69964f7285ccd66a4c1b14c61f3675982/atlas-json-parent/atlas-json-core/src/main/java/io/atlasmap/json/core/JsonFieldReader.java#L59