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

I have strange behaviour of filter 'unique' #1270

Open
typo3ua opened this issue Jul 24, 2020 · 0 comments
Open

I have strange behaviour of filter 'unique' #1270

typo3ua opened this issue Jul 24, 2020 · 0 comments

Comments

@typo3ua
Copy link

typo3ua commented Jul 24, 2020

I have the array in JSON format:

[
  {
      "id": 0,
      "type": "Type Zero",
      "date": "2020-02-22",
      "phone": 380001000000,
      "images":  ""
  },
  {
      "id": 1,
       "type": "Type One",
      "date": "2020-04-24",
      "phone": 380001000000,
      "images": ""
  },
  {
      "id": 2,
      "type": "Type Two",
      "date": "2020-07-08",
      "phone": 380002000000,
      "images": ""
  }
]

{%- assign model = site.data.models | map: "phone" | uniq -%}

I get: Liquid Exception: no implicit conversion of String into Integer in... hints at "phone", but is not problem i changed it to...

[
  {
      "id": 0,
      "type": "Type Zero",
      "date": "2020-02-22",
      "phone": "380001000000",
      "images":  ""
  },
  {
      "id": 1,
       "type": "Type One",
      "date": "2020-04-24",
      "phone": "380001000000",
      "images": ""
  },
  {
      "id": 2,
      "type": "Type Two",
      "date": "2020-07-08",
      "phone": "380002000000",
      "images": ""
  }
]

{%- assign model = site.data.models | map: "phone" | uniq -%}

<ul>
  {%- for too in model -%}
  <li>{{ too.id }} / {{ too.type }} / {{ too.data }} / {{ too.phone }} / {{ too.images }}</li>
  {%- endfor -%}
</ul>

....in the array model i expected get

[
  {
      "id": 0,
      "type": "Type Zero",
      "date": "2020-02-22",
      "phone": "380001000000",
      "images":  ""
  },
  {
      "id": 2,
      "type": "Type Two",
      "date": "2020-07-08",
      "phone": "380002000000",
      "images": ""
  }
]
<ul>
  <li> 0 / Type Zero / 2020-02-22 / 380001000000 / </li>
  <li> 1 / Type Two / 2020-07-08 / 380002000000 / </li>
</ul>

but in the array model i get nothing if exactly I see

Now I see only one field "phone" i do not understand where other fields...?

<ul>
  <li> / / / 380001000000 / </li>
  <li> / / / 380002000000 / </li>
</ul>

Why? Did I miss something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant