Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with nested attributes #331

Open
Al64v opened this issue Feb 20, 2024 · 3 comments
Open

Problem with nested attributes #331

Al64v opened this issue Feb 20, 2024 · 3 comments
Labels
support Users asking how to solve a specific issue

Comments

@Al64v
Copy link

Al64v commented Feb 20, 2024

Good afternoon! Can you please tell me how I can convert this message using jslt?
Input JSON:

[ {
  "cal" : {
    "Name" : "one hour",
    "Type" : "F",
    "calText" : {
      "Text" : [ {
        "Language" : "RU",
        "Description" : "one hour"
      }, {
        "Language" : "EN",
        "Description" : "5/8  hour cal (integration)"
      } ]
    },
    "calSchedule" : {
      "calDay" : [ {
        "Date" : "31.10.2024",
        "DateType" : "W"
      }, {
        "Date" : "01.01.2024",
        "DateType" : "H"
      } ]
    }
  }
} ]


Output JSON after JSLT transformation:
{
    "cal_head": [
        {
            "cal": "one hour",
            "type": "F"
        }
    ],
    "cal_description": [
        {
            "cal": "one hour",
            "language": "RU",
            "description": "one hour"
        },
        {
            "cal": "5/8 hour cal (integration)",
            "language": "EN",
            "description": "5/8  hour cal (integration)"
        }
    ],
    "cal_schedule": [
        {
            "cal": "one hour",
            "date": "10/31/2024",
            "day_type": "W"
        },
        {
            "cal": "one hour",
            "date": "01/01/2024",
            "day_type": "H"
        }
    ]
}



the main problem is that from the outer loop cannot be passed as a constant to the inner loop(
@larsga
Copy link
Collaborator

larsga commented Feb 20, 2024

the main problem is that from the outer loop cannot be passed as a constant to the inner loop(

Have you tried defining a variable in the outer loop and referring to it from the inner?

@larsga larsga added the support Users asking how to solve a specific issue label Feb 20, 2024
@Al64v
Copy link
Author

Al64v commented Feb 29, 2024

@larsga Thank you! I figured out the current problem!

Can you please tell me how I can remove the quotes?
I have an input attribute in quotes, and if I try to convert it using jslt, the value will also remain in quotes

For example:
Input JSON:
{"date": "29.02.2024"}

JSLT-Transformation:
{"date": .date}

expected output message:
{"date": 29.02.2024}

but in fact I get the value in quotes:
{"date": "29.02.2024"}

and now the date attribute is not a date, but a string?

@larsga
Copy link
Collaborator

larsga commented Feb 29, 2024

Please make new issues for new problems.

This:

expected output message:
{"date": 29.02.2024}

Is not JSON, so there is no way JSLT can produce it. JSON doesn't have built-in date types. So what you're asking is impossible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Users asking how to solve a specific issue
Projects
None yet
Development

No branches or pull requests

2 participants