title: How to filter JSON Data in JS
body: <p>I have a of JSON Data of jobs where each job contain the following information</p>
  <pre><code>{
    jobs: [
      {
        jobseeker_create_job_id: 1,
        job_title: &quot;Fashion Designer&quot;,
        job_description: &quot;Fashion Designer&quot;,
        salary: &quot;{'value': 2, 'label': 'Rs.10,001/- to Rs12,000/-'}&quot;,
        preferred_location: &quot;[]&quot;,
        trade: &quot;&quot;,
        trade_cat: &quot;&quot;,
        perks: &quot;[]&quot;,
        pia_id: 5,
        valid_till: &quot;2020-07-22&quot;,
        note: &quot;none&quot;,
        CreatedDate: &quot;2020-07-22T15:49:32.120875+05:30&quot;,
        ModifiedBy: null,
        ModifiedDate: null,
        DeletedBy: null,
        DeletedDate: null,
        pia_name: &quot;BPO Organisation&quot;,
      },
      {
        jobseeker_create_job_id: 2,
        job_title: &quot;Fashion Designer Intern&quot;,
        job_description: &quot;Fashion Designer Intern&quot;,
        salary: &quot;{'value': 2, 'label': 'Rs.10,001/- to Rs12,000/-'}&quot;,
        preferred_location:
          &quot;[{'state': {'value': 22, 'label': 'Maharashtra'}, 'district': {'value': 2821, 'label': 'Solapur'}}]&quot;,
        trade: &quot;domain&quot;,
        trade_cat: &quot;{'value': 17, 'label': 'FASHION DESIGN'}&quot;,
        perks: &quot;[]&quot;,
        pia_id: 0,
        valid_till: &quot;2020-07-22&quot;,
        note: &quot;no&quot;,
        CreatedDate: &quot;2020-07-22T15:51:37.256110+05:30&quot;,
        ModifiedBy: null,
        ModifiedDate: null,
        DeletedBy: null,
        DeletedDate: null,
        pia_name: &quot;Admin&quot;,
      },
      {
        jobseeker_create_job_id: 4,
        job_title: &quot;Test experience&quot;,
        job_description: &quot;Test experience&quot;,
        salary: &quot;{'value': 2, 'label': 'Rs.10,001/- to Rs12,000/-'}&quot;,
        preferred_location:
          &quot;[{'state': {'value': 22, 'label': 'Maharashtra'}, 'district': {'value': 2821, 'label': 'Solapur'}}]&quot;,
        trade: &quot;&quot;,
        trade_cat: &quot;&quot;,
        perks: &quot;[]&quot;,
        pia_id: 5,
        valid_till: &quot;2020-07-23&quot;,
        note: &quot;none&quot;,
        CreatedDate: &quot;2020-07-23T12:35:01.708645+05:30&quot;,
        ModifiedBy: null,
        ModifiedDate: null,
        DeletedBy: null,
        DeletedDate: null,
        pia_name: &quot;BPO Organisation&quot;,
      },
      {
        jobseeker_create_job_id: 5,
        job_title: &quot;Test2 Update&quot;,
        job_description: &quot;asd&quot;,
        salary: &quot;{'value': 3, 'label': 'Rs.12,001/- to Rs.15000/-'}&quot;,
        preferred_location:
          &quot;[{'state': {'value': 22, 'label': 'Maharashtra'}, 'district': {'value': 2821, 'label': 'Solapur'}}, {'state': {'value': 22, 'label': 'Maharashtra'}, 'district': {'value': 2763, 'label': 'Pune'}}]&quot;,
        trade: &quot;&quot;,
        trade_cat: &quot;&quot;,
        perks: &quot;[]&quot;,
        pia_id: 5,
        is_admin: false,
        is_active: true,
        is_approve: true,
        valid_till: &quot;2020-07-23&quot;,
        note: &quot;none&quot;,
        CreatedDate: &quot;2020-07-23T13:11:48.132243+05:30&quot;,
        ModifiedBy: null,
        ModifiedDate: null,
        DeletedBy: null,
        DeletedDate: null,
        pia_name: &quot;BPO Organisation&quot;,
      },
    ]
  }
  
  </code></pre>
  <p>I want to filter the JSON using preferred_location variable</p>
  <pre><code>preferred_location: &quot;[{'state': {'value': 22, 'label': 'Maharashtra'}, 'district': {'value': 2821, 'label': 'Solapur'}}, {'state': {'value': 22, 'label': 'Maharashtra'}, 'district': {'value': 2763, 'label': 'Pune'}}]&quot;,
  </code></pre>
  <p>Example : If user selects solapur ( Maharashtra ) and district (Solapur)</p>
  <p>The list should return only those jobs which contain this values in the preferred_location</p>
  <p>I tried filtereing using job description like this</p>
  <pre><code>if (values.designation != null) {
  //selected will hold the input values which user will enter
  let selected = [].slice.call(values.designation).map((o) =&gt; {
  return o.value;
  });
  
  // list contains JSON Data of jobs 
  list = list.filter((e) =&gt; {
  let designation_json = e.designation.replace(/'/g, '&quot;');
  let designation_json_decoded = JSON.parse(designation_json);
  return selected.includes(
  parseInt(designation_json_decoded.value)
       );
    });
  }
  </code></pre>
  <p>I want to do the same for preferred_location variable but not able to do so.</p>