vue-json-pretty icon indicating copy to clipboard operation
vue-json-pretty copied to clipboard

有搜索功能吗?Is there a search function?

Open ztg-zlu opened this issue 4 years ago • 7 comments

这个组件,有搜索功能吗??

ztg-zlu avatar Apr 21 '21 07:04 ztg-zlu

This would be nice to have for large JSON objects.

JowJoris avatar Apr 14 '23 13:04 JowJoris

Hi @leezng is this something you are planning to include? It would be handy for filtering large datasets like @JowJoris mentioned.

JoshuaRobertson avatar Nov 16 '23 14:11 JoshuaRobertson

I'm very sorry that this issue has not been dealt with. I expect to release a minimum usable method in the next version.

Here, I also hope to collect everyone’s opinions. My initial idea is to search for key and value, and use ref for external calls. If you have any ideas, please reply.

leezng avatar Nov 21 '23 02:11 leezng

@leezng no need to apologise, it's a great package.

I have a few points to consider:

  • It would be useful if it could search nested arrays
  • A strict mode so it can be like or exact

JoshuaRobertson avatar Nov 21 '23 14:11 JoshuaRobertson

@leezng no need to apologise, it's a great package.

I have a few points to consider:

  • It would be useful if it could search nested arrays
  • A strict mode so it can be like or exact

@JoshuaRobertson strict mode is a good suggestion. Can you provide a specific example for the first point? I'm not sure what effect you want to achieve.

leezng avatar Nov 22 '23 10:11 leezng

@leezng I think a strict mode for the search would help so you can filter by certain search terms. If we use this example array:

const users = [
  { name: 'John', age: 30, hobbies: ['reading', 'coding'] },
  { name: 'Alice', age: 25, hobbies: ['cooking', 'traveling'] },
  { name: 'Bob', age: 35, hobbies: ['gardening', 'gaming'] }
]

something like:

  • Strict: only return array items that exactly match, such as "coding" would return one result (John)
  • Like: return array items that include any of the search, such as "co" would return two results (John & Alice)

What do you think?

JoshuaRobertson avatar Dec 04 '23 13:12 JoshuaRobertson