WorkMaze / JUST.net

JUST - JSON Under Simple Transformation (XSLT equivalent for JSON).
MIT License
174 stars 54 forks source link

Property reference from higher level is lost when transformed value is nested in new object. #292

Open JuanHattingh opened 11 months ago

JuanHattingh commented 11 months ago

I am facing an issue in which my transformation output is not what is expected. Any time I nest the expected output from a previous evaluation at a higher level inside a new nested object, I get null results. For example, consider the following.

Input:

{ 
  "id": "751dae4f8ddf"
}

Tranformer:

{
    "level1": {
        "quoteId": "#valueof($.id)",
        "resolved": "#valueof($.quoteId)",
        "level2": {
            "notResolved1": "#valueof($..quoteId)",
            "level3": {
                "notResolved2": "#valueof($..quoteId)"
            }
        }
    }
}

Output:

{
    "level1": {
        "quoteId": "751dae4f8ddf",
        "resolved: "751dae4f8ddf",
        "level2": {
            "notResolved1": null,
            "level3": {
                "notResolved2": null
            }
        }
    }
}

Am I missing something here or is this considered a defect?

Courela commented 11 months ago

Probably it's a defect, you shouldn't be able to resolve

...
    "resolved": "#valueof($.quoteId)"
...

since you have "level1" in transfomer...

I'll have to check it.

Courela commented 11 months ago

Yep, it's a bug alright, the EvaluationMode.LookInTransformed only looks from the parent of the transformed field, instead of the whole transformer, that's why you are able to get a value for

...
    "resolved": "#valueof($.quoteId)"
...

This should be the result

{
    "level1": {
        "quoteId": "123",
        "resolved": null,
        "level2": {
            "notResolved1": "123",
            "level3": {
                "notResolved2": "123"
            }
        }
    }
}
JuanHattingh commented 10 months ago

@Courela, Any idea when the PR will be completed and a new version available with the fix?

Courela commented 10 months ago

I'm not the owner, just a contributor, I don't call the shots

WorkMaze commented 10 months ago

The PR seems to have merge conflicts.