How to query a JSON

Is it possible to query a JSON dataSheet? Maybe it is a silly question but I am starting to test the JSON option in the data source.

Thanks!

Ok! I just checked one way to achieve what I wanted. I don’t know if it can be done in the query field in the datasheet but I have written a small script in the list and it works just fine. I am not sure if it is the appropriate way but I am filtering through a Javascript script.

Hi, querying something requires some kind of query engine, package or database. JSON files are basically just text files so you need to iterate it either with a script or implement some kind of hack with e.g. this package: https://www.npmjs.com/package/jsonata

P.S. the query field in Data sheet works only with the Data plugins. The plugin code then decides what to do with the query field’s input.

Thank you so much for your guidance. I am right now writing some scripts to do the filtering and I will explore jsonata which seems to fit very well to manage the JSON file. Now that I am seeing how the JSON works, I believe it fits really well in my project. In fact I am sure the appropriate approach for my project is:

  • Manage the collection of documents with JSON as it is data that is not going to change over time. I will just add new documents from time to time and that can be done with this formal.

  • Manage the users information (scores, personal info, etc.) as collections in Firestore as it is more dynamic and needs to be consulted and modified periodically.

I am in the process to do the transition to this model. Thank you very much because I use to find useful information over here.

Ok. I am right now trying to implement jsonata to be used with one of the collection I am testing in JSON. I am sure I am going to ask obvious questions but it is the first node package that I am going to use so I am a little lost.

  • First step I have installed jsonata in my computer with the npm install jsonata.
  • Then I am guessing that I have import the jsonata package in my project. This is where I begin to doubt. I am going to guess that I have to import it in the screen where I have the list based in the JSON. I open the Script editor and add

import jsonata from ‘.jsonata’;

I am not sure about this. If so, now I am guessing again that I have to open the Edit script for the list and write the query for jsonata there?


I would really appreaciate how to make it work.

Thank you.

Just an update to this. I have tried to implement Jsonata but I didn’t know how to proceed so I decided to go the Javascript path and I achieved to have a combination of several filters working very nicely. Here I share the code just in case is useful to someone:

Even though I am implementing scripts to approach the dataSource, I like what jsonata has to offer and I believe it has a lot of potential so I would love to learn how to use it with my project in React Studio but I don’t know how to get it done. So far I have installed the package in my computer, I import it in the header of the Screen where I intend to use it, but I don’t how or where I would place its language to make the query. Any tips? Thanks!