I make an online store using json to display products in conjunction with javascript and jquery. In json, I keep goods from one category, they are displayed on the page "women's sports clothing."

The question is, if I add products from all categories to the same array, with the help of which function can I display only the necessary goods on different category pages?

That is, how to make a selection from json? You need exactly the code that performs this, if possible.

If this method is wrong, then it is better to create your own json file for each category of goods?

Here is the json part of the file:

{ "1234": { "name": "spodnie", "cost":60, "description": "spodnie bawelniane", "orer":1, "img":"leggins/50.jpg" }, 

function code is needed in javascript

  • json is just a textual representation of the data and is not an alternative to the database. If you want to store data (goods) in a json file, you will have to upload the file to the client as a whole, parse it into the javascript array and then work with the array, displaying the necessary information to the user. It is preferable to use a database, if you want to use javascript, you can connect node.js in conjunction with mongoDb. - Alexander the Great
  • @Alexander. A great man has obviously unloaded the file where necessary, and asks how to filter. If there is everything about all 20 products, then it is possible and does not make sense to create a database - teran
  • What field are you going to filter? by the way, your code shows not an array, but an object with keys. - teran
  • @teran Exactly, the file is unloaded. You need to filter by id. - Mariia Kramarenko 1:32 pm
  • @Alexander Velikiy I don’t need an explanation of what I should do with the code and what the dd is better, I know that:) I need a filtering function that would filter the given array. - Mariia Kramarenko 1:32 pm

0