GithubHelp home page GithubHelp logo

kapilkashyap / jquery-filter-json-plugin Goto Github PK

View Code? Open in Web Editor NEW
16.0 16.0 4.0 266 KB

A jQuery utility that allows you to filter a JSON based on properties

Home Page: http://kapilkashyap.github.io/jquery-filter-json-plugin/

License: GNU General Public License v2.0

JavaScript 100.00%
filter javascript javascript-library jquery jquery-filter-json jquery-plugin json

jquery-filter-json-plugin's Introduction

Hi, I'm Kapil Kashyap👋

     GitHub User's stars     GitHub followers

A passionate frontend engineer who wishes to contribute back to the Open-Source community via innovations & solutions.

About me!

  • 👨🏿‍💻 Working on dynamically transmuting a JSON into a Class with private properties and accessor methods, at runtime!
  • 🌱 Learning how to efficiently setup a front-end project using esbuild
  • 🚀 Exploring different state management libraries and their trade-offs
  • 👯 Looking to collaborate on any Open-Source that can use my expertise in front-end technologies
  • 💓 Love high altitude treks, photography, sports, solving puzzles and recreating interactive retro games - Check this out Snake 🎮

Tech stack

html5     css3     javascript     typescript     nodejs     react     redux     Jest     d3js     git     java    

Connect with me

kapilkashyap     user:1694813     kapilkashyaps    

Some stats

kapilkashyap     kapilkashyap

jquery-filter-json-plugin's People

Contributors

kapilkashyap avatar mauricios avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

jquery-filter-json-plugin's Issues

Is there a way to use "value" of nested object as "property"

Hello!

Lets consider following JSON format.

var dummyJSON = [
    {
        "id":"",
        "additionalProp":{
            "filterName":"name",
            "filterValue":"XYZ" 

        }
    }
]

What if I want to filter based on additionalProp['filterName']==="name" ??

Following code fils to work

filter = $.fn.filterJSON(dummyJSON, {
      property: [additionalProp['filterName']==="name" ], 
      wrapper: true,
      value: ["XYZ"],
      checkContains: false,
      startsWith: true,
      matchCase: false,
      avoidDuplicates: true,
      sort: false
});

Thanks.

How to use jquery-filter-json-plugin with multiple property and multiple values in large json

[
{
"machineId": "1A",
"serialNo": "123",
"city": "",
"Mode": "ON"
},
{
"machineId": "2B",
"serialNo": "123",
"city": "",
"Mode": "OFF"
},
{
"machineId": "3A",
"serialNo": "123",
"city": "NewCity",
"Mode": "OFF"
},
{
"machineId": "1A",
"serialNo": "123",
"city": "",
"Mode": "OFF"
},
{
"machineId": "1A",
"serialNo": "123",
"city": "",
"Mode": "Default"
}
]

in above json, lets say i want to filter, machineId having value "IA", and Mode having values "ON and OFF"

I tried something like

property: ["machineId", "Mode"],
value: ["1A,ON,OFF"],

it did not work, Please suggest how to use the plugin in this case

Retrieve The main Object Instead of child

Consider following Array

var dummyJSON = [
    {
        "id":"123",
        "additionalProp":{
            "name":"XYZ",
            "designation":"Manager",
            "hobbies":"Football"
        }
    },
    {
        "id":"345",
        "additionalProp":{
            "name":"ABC",
            "designation":"XYZ",
            "hobbies":"Cricket"
        }
    }
]

Now, if I type following,

var x = $.fn.filterJSON(dummyJSON, {
      property: ["name"],     
      value: ["XYZ"],
      wrapper: true,
      checkContains: false,
      startsWith: true,
      matchCase: false,
      avoidDuplicates: true,
      sort: false
});

I get additionalProp of 1st object, not the whole object.

value of x

            {
            "name":"XYZ",
            "designation":"Manager",
            "hobbies":"Football"
            }

expected value of x

    {
        "id":"123",
        "additionalProp":{
            "name":"XYZ",
            "designation":"Manager",
            "hobbies":"Football"
        }
    }

Add package to npm

It will be nice to use this package form a CDN. can you add this package to NPM registry so it will be available in UNPKG?

Sort Comparator Example

Could you please give an an example of how to use the Sort Comparator?

Also, I'm trying to use filterJSON on another variable that's already set by filterJSON, is this possible?

var data = [{"kategori":"p","kommunenavn":"oslo","kommunenummer":"301","postnummer":"1","poststed":"oslo"},
{"kategori":"g","kommunenavn":"oslo","kommunenummer":"301","postnummer":"577","poststed":"oslo"},{"kategori":"g","kommunenavn":"oslo","kommunenummer":"301","postnummer":"578","poststed":"oslo"},{"kategori":"g","kommunenavn":"oslo","kommunenummer":"301","postnummer":"579","poststed":"oslo"},{"kategori":"g","kommunenavn":"oslo","kommunenummer":"301","postnummer":"580","poststed":"oslo"},{"kategori":"g","kommunenavn":"oslo","kommunenummer":"301","postnummer":"581","poststed":"oslo"},{"kategori":"p","kommunenavn":"moss","kommunenummer":"104","postnummer":"1510","poststed":"moss"},{"kategori":"g","kommunenavn":"sarpsborg","kommunenummer":"105","postnummer":"1711","poststed":"sarpsborg"},{"kategori":"g","kommunenavn":"askim","kommunenummer":"124","postnummer":"1814","poststed":"askim"},{"kategori":"g","kommunenavn":"skedsmo","kommunenummer":"231","postnummer":"2010","poststed":"strømmen"}];
var locations = $.fn.filterJSON(data, {
    property: ["kategori"],
    value: ["g"],
    wrapper: true,
    startsWith: true,
});

var municipalities = $.fn.filterJSON(locations, {
    property: ["kommunenummer"],
    wrapper: true,
    startsWith: true,
    avoidDuplicates: true,
    sort: true,
   sortOrder: "asc"
});

The result from locations is exactly the same as the result from municipalities...

Add bower support

Bower is a package manager for frameworks, libraries, assets, and utilities of a website.

With bower support we can have better tracking of this utility in the projects.

More about Bower https://bower.io/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.