I’m pulling data from an API into Postgres. One of the fields/columns in the database is JSON. The structure of the JSON is different for each record I pull into the database.
Each of these records is the parent of a set of items and the traits are how we filter the items in a list. I want to display them in a filter list like the image below. They will always be one of two types, a group of checkboxes or a range with min/max, but the code will need to be able to determine which type to use based on the data in the JSON at display time. Both types can exist in the JSON for one record.
I guess it should be possible but it is going to involve a lot of string manipulation to turn each response into useable data. If you are sending the data (guessing it’s a game) then perhaps you should look at structuring the data better, if you are interfacing with someone else’s then you will need to process it manually. Difficult to be precise due to the limited information
The data come from an API. I do not have the ability to structure it differently and will not know what the data will look like from one record to the next except that it will be either, a list of items or an item with min and max value. So the solution will need to be able to infer which of the two options it is before building the data structure.
If you don’t find anyone else send me a PM. I know how to handle the JSON to make it more “predictable” so it’s easier to handle, but I’m not experienced with the front-end to do the data pickers. I could for example define in the JSON the fields “checkbox”, “minmax”, etc. so you can define a predictable schema for those. To check if this specific row is of such type, you can just check (e.g.) “checkbox” is null to hide the unrelated data pickers. So you create the data pickers (checkbox, minmax, slider?) and show/hide them (dmx-show) depending on a JSON variable I tell you to check