Formatting JSON Data

Hi, I’m brand new to using JSON and figured out most of what I need but I have 2 questions.

I was wondering how to sort out the data according to a field. When setting the expression for the repeat row I don’t see any option on how to sort it.

Second, what is the best way to display info with each item on a new row?

Here is the test data I am using

    [
  {
    "sitename": "Google",
    "url": "google.com",
    "logo": "https://www.google.com/images/branding/googlelogo/1x/googlelogo_light_color_272x92dp.png",
    "order": "2",
    "test": "one, two, three, four, five",
    "test2": [ "one", "two", "three", "four", "five" ]
  },
  {
    "sitename": "Bing",
    "url": "bing.com",
    "logo": "https://1000logos.net/wp-content/uploads/2021/11/Bing-logo.png",
    "order": "1",
    "test": "one, two, three, four, five",
    "test2": [ "one", "two", "three", "four", "five" ]
  }
]

and this is what my Wappler project is

<!-- Wappler include head-page="layouts/main" fontawesome_5="cdn" bootstrap5="local" is="dmx-app" id="index" appConnect="local" components="{dmxFormatter:{},dmxTyped:{}}" -->

<dmx-json-datasource id="jsonDS1" is="dmx-serverconnect" url="/sites.json"></dmx-json-datasource>
<div class="container">
    <div class="row" is="dmx-repeat" id="repeat1" dmx-bind:repeat="jsonDS1.data">
        <div class="col-12">




            <h1>{{sitename}}</h1>
            <img dmx-bind:src="logo" width="200" class="bg-primary">
            <p>{{url}}</p>
            <p dmx-html="test.replace(',', '&lt;br&gt;').titlecase()"></p>
            <p dmx-html="test2"></p>
            <p dmx-html="order"></p>
        </div>
    </div>
</div>
<meta name="ac:route" content="/">

For the “test” and “test2” I don’t know which way is better to have the data or how to separate the items into their own row. I got it to separate on “test” by using replacing the comma with a break, but I assume there is a better way.

Any help is appreciated.

Use a Data View - assign it to the JSON data source and utilise its capabilities on the client - includes sorting, filtering, count, sum, grouping, etc…

As with most things in Wappler, it’s powerful, it’s close to or exactly what you want but it’s probably poorly documented - c’est La Vie

This might help.

Thanks for the reply. I think I have the data view setup correctly but wanted to verify.

I still add the JSON data source as before. Then I set the data view source to be the JSON data and set my filters/sort here. Then in a repeat row I would set the expression to be the data view data. Then set my paragraph for example, to pull from the repeat row data.

That’s it. Try it and let me know

It’s working, thanks for the help.

Cool.