过滤json字符串数据

时间:2015-10-08 08:33:10

标签: javascript json

我的Json字符串:

  [ {
      "attributes" : {
        "type" : "Contact",
        "url" : "/services/data/v34.0/sobjects/Contact/003N000000PIZkAIAX"
      },
      "Id" : "003N000000PIZkAIAX",
      "Name" : "Infosys Ltd.",
      "Email" : "asenok09@mail.ru",
      "AccountId" : "001N000000U5duZIAR",
      "MailingStreet" : "Mahadevpura, Doddanekundi Village Krishnarajpuram Hobli,Bangalore East Taluk",
      "MailingCity" : "bangalore",
      "MailingPostalCode" : "560048",
      "MailingState" : "Karnataka",
      "MailingCountry" : "India",
      "Location__Latitude__s" : 12.954614,
      "Location__Longitude__s" : 77.648959,
      "CurrencyIsoCode" : "CAD",
      "Account" : {
        "attributes" : {
          "type" : "Account",
          "url" : "/services/data/v34.0/sobjects/Account/001N000000U5duZIAR"
        },
        "Name" : "Test company 1",
        "Id" : "001N000000U5duZIAR",
        "RecordTypeId" : "01290000000Rw2LAAS",
        "CurrencyIsoCode" : "CAD"
      }
    }, {
      "attributes" : {
        "type" : "Contact",
        "url" : "/services/data/v34.0/sobjects/Contact/003N0000007IEZ2IAO"
      },
      "Id" : "003N0000007IEZ2IAO",
      "Name" : "ryete",
      "AccountId" : "001N0000008BKnaIAG",
      "MailingStreet" : "ghfhgfh",
      "MailingCity" : "bangalore",
      "MailingPostalCode" : "560017",
      "MailingCountry" : "France",
      "CurrencyIsoCode" : "USD",
      "Account" : {
        "attributes" : {
          "type" : "Account",
          "url" : "/services/data/v34.0/sobjects/Account/001N0000008BKnaIAG"
        },
        "Name" : "service test",
        "Id" : "001N0000008BKnaIAG",
        "RecordTypeId" : "01290000000Rw2LAAS",
        "CurrencyIsoCode" : "USD"
      }
    }, {
      "attributes" : {
        "type" : "Contact",
        "url" : "/services/data/v34.0/sobjects/Contact/003N000000GIoXJIA1"
      },
      "Id" : "003N000000GIoXJIA1",
      "Name" : "test",
      "Email" : "cseteja@gmail.com",
      "AccountId" : "001N0000005jCueIAE",
      "MailingStreet" : "13th street",
      "MailingCity" : "Bangalore",
      "MailingPostalCode" : "3434",
      "MailingState" : "Karnataka",
      "MailingCountry" : "India",
      "Location__Latitude__s" : 28.2460347,
      "Location__Longitude__s" : -81.2947529,
      "CurrencyIsoCode" : "CAD",
      "Account" : {
        "attributes" : {
          "type" : "Account",
          "url" : "/services/data/v34.0/sobjects/Account/001N0000005jCueIAE"
        },
        "Name" : "Account3",
        "Id" : "001N0000005jCueIAE",
        "RecordTypeId" : "01290000000Rw2LAAS",
        "CurrencyIsoCode" : "USD"
      }
    }, {
      "attributes" : {
        "type" : "Contact",
        "url" : "/services/data/v34.0/sobjects/Contact/003N000000RGJq1IAH"
      },
      "Id" : "003N000000RGJq1IAH",
      "Name" : "Ace Infosys",
      "AccountId" : "001N000000SS0nDIAT",
      "MailingStreet" : "76/1, 2nd Floor, 2nd Main, Seshadripuram, Seshadripuram",
      "MailingCity" : "Bangalore",
      "MailingPostalCode" : "560020",
      "MailingState" : "Karnataka",
      "MailingCountry" : "India",
      "Location__Latitude__s" : 12.9981895,
      "Location__Longitude__s" : 77.580900,
      "CurrencyIsoCode" : "EUR",
      "Account" : {
        "attributes" : {
          "type" : "Account",
          "url" : "/services/data/v34.0/sobjects/Account/001N000000SS0nDIAT"
        },
        "Name" : "test company 3",
        "Id" : "001N000000SS0nDIAT",
        "RecordTypeId" : "01290000000Rw2LAAS",
        "CurrencyIsoCode" : "CAD"
      }
    }, {
      "attributes" : {
        "type" : "Contact",
        "url" : "/services/data/v34.0/sobjects/Contact/003N000000RGJpSIAX"
      },
      "Id" : "003N000000RGJpSIAX",
      "Name" : "Sunstar Infosys",
      "AccountId" : "001N000000SS0n8IAD",
      "MailingStreet" : "6th Cross Rd, Koramangala 6 Block, Koramangala,",
      "MailingCity" : "Bangalore",
      "MailingPostalCode" : "560095",
      "MailingState" : "Karnataka",
      "MailingCountry" : "India",
      "Location__Latitude__s" : 12.9383453,
      "Location__Longitude__s" : 77.6235624,
      "CurrencyIsoCode" : "EUR",
      "Account" : {
        "attributes" : {
          "type" : "Account",
          "url" : "/services/data/v34.0/sobjects/Account/001N000000SS0n8IAD"
        },
        "Name" : "test company 2",
        "Id" : "001N000000SS0n8IAD",
        "RecordTypeId" : "01290000000Rw2LAAS",
        "CurrencyIsoCode" : "CAD"
      }
    }, {
      "attributes" : {
        "type" : "Contact",
        "url" : "/services/data/v34.0/sobjects/Contact/003N000000I7KoGIAV"
      },
      "Id" : "003N000000I7KoGIAV",
      "Name" : "jaspal bhatiya",
      "Email" : "jass@gmail.com",
      "AccountId" : "001N000000ICcaXIAT",
      "MailingStreet" : "jaspal madivala",
      "MailingCity" : "Bangalore",
      "MailingPostalCode" : "587101",
      "MailingCountry" : "India",
      "CurrencyIsoCode" : "CAD",
      "Account" : {
        "attributes" : {
          "type" : "Account",
          "url" : "/services/data/v34.0/sobjects/Account/001N000000ICcaXIAT"
        },
        "Name" : "bharattt",
        "Id" : "001N000000ICcaXIAT",
        "RecordTypeId" : "01290000000Rw2LAAS",
        "CurrencyIsoCode" : "CAD"
      }
    }, {
      "attributes" : {
        "type" : "Contact",
        "url" : "/services/data/v34.0/sobjects/Contact/003N0000007JD6tIAG"
      },
      "Id" : "003N0000007JD6tIAG",
      "Name" : "Deshmukh sachin",
      "Email" : "dr.sachindeshmukh@gmail.com",
      "AccountId" : "001N0000008BScYIAW",
      "MailingCity" : "Bangalore",
      "MailingPostalCode" : "560038",
      "MailingCountry" : "India",
      "Location__Latitude__s" : 12.9715987,
      "Location__Longitude__s" : 77.5945627,
      "CurrencyIsoCode" : "EUR",
      "Account" : {
        "attributes" : {
          "type" : "Account",
          "url" : "/services/data/v34.0/sobjects/Account/001N0000008BScYIAW"
        },
        "Name" : "joiuy",
        "Id" : "001N0000008BScYIAW",
        "RecordTypeId" : "01290000000Rw2LAAS",
        "CurrencyIsoCode" : "EUR"
      }
    }, {
      "attributes" : {
        "type" : "Contact",
        "url" : "/services/data/v34.0/sobjects/Contact/003N000000JzQfgIAF"
      },
      "Id" : "003N000000JzQfgIAF",
      "Name" : "Elisha Babamuratov",
      "Email" : "elisha@arts.co.il",
      "AccountId" : "001N000000M3ZSjIAN",
      "MailingCity" : "bangalore",
      "MailingPostalCode" : "560017",
      "MailingState" : "Karnataka",
      "MailingCountry" : "India",
      "Location__Latitude__s" : 12.9715987,
      "Location__Longitude__s" : 77.5945627,
      "CurrencyIsoCode" : "CAD",
      "Account" : {
        "attributes" : {
          "type" : "Account",
          "url" : "/services/data/v34.0/sobjects/Account/001N000000M3ZSjIAN"
        },
        "Name" : "UNKNOWN",
        "Id" : "001N000000M3ZSjIAN",
        "RecordTypeId" : "01290000000Rw2LAAS",
        "CurrencyIsoCode" : "CAD"
      }
    }, {
      "attributes" : {
        "type" : "Contact",
        "url" : "/services/data/v34.0/sobjects/Contact/003N000000RGJqVIAX"
      },
      "Id" : "003N000000RGJqVIAX",
      "Name" : "Printo Infosys Campus",
      "AccountId" : "001N000000SSawfIAD",
      "MailingStreet" : "#47,Terminal Building Basement Infosys Technologies Ltd, #44,, 6/78, Hosur Rd, Electronic City",
      "MailingCity" : "Bangalore",
      "MailingPostalCode" : "560100",
      "MailingState" : "Karnataka",
      "MailingCountry" : "India",
      "Location__Latitude__s" : 12.8485706,
      "Location__Longitude__s" : 77.672219,
      "CurrencyIsoCode" : "EUR",
      "Account" : {
        "attributes" : {
          "type" : "Account",
          "url" : "/services/data/v34.0/sobjects/Account/001N000000SSawfIAD"
        },
        "Name" : "test company 4",
        "Id" : "001N000000SSawfIAD",
        "RecordTypeId" : "01290000000Rw2LAAS",
        "CurrencyIsoCode" : "CAD"
      }
    }, {
      "attributes" : {
        "type" : "Contact",
        "url" : "/services/data/v34.0/sobjects/Contact/003N000000I74FPIAZ"
      },
      "Id" : "003N000000I74FPIAZ",
      "Name" : "jaspal John",
      "Email" : "jassibhatiya11@gmail.com",
      "AccountId" : "001N000000LhcBlIAJ",
      "MailingStreet" : "jaspal madivala",
      "MailingCity" : "Bangalore",
      "MailingPostalCode" : "587101",
      "MailingState" : "Karnataka",
      "MailingCountry" : "India",
      "CurrencyIsoCode" : "CAD",
      "Account" : {
        "attributes" : {
          "type" : "Account",
          "url" : "/services/data/v34.0/sobjects/Account/001N000000LhcBlIAJ"
        },
        "Name" : "BEL",
        "Id" : "001N000000LhcBlIAJ",
        "RecordTypeId" : "01290000000Rw2LAAS",
        "CurrencyIsoCode" : "CAD"
      }
    }, {
      "attributes" : {
        "type" : "Contact",
        "url" : "/services/data/v34.0/sobjects/Contact/003N000000Ibt9HIAR"
      },
      "Id" : "003N000000Ibt9HIAR",
      "Name" : "dsFTAERTE",
      "Email" : "csedeep7@gmail.com",
      "AccountId" : "001N0000008BJVOIA4",
      "MailingStreet" : "NO.1,LS TRANQUIL Appartments\r\nSR LAYOUT ,MURUGESHPALYA",
      "MailingCity" : "bangalore",
      "MailingPostalCode" : "560017",
      "CurrencyIsoCode" : "CAD",
      "Account" : {
        "attributes" : {
          "type" : "Account",
          "url" : "/services/data/v34.0/sobjects/Account/001N0000008BJVOIA4"
        },
        "Name" : "Account3",
        "Id" : "001N0000008BJVOIA4",
        "RecordTypeId" : "01290000000Rw2LAAS",
        "CurrencyIsoCode" : "USD"
      }
    }, {
      "attributes" : {
        "type" : "Contact",
        "url" : "/services/data/v34.0/sobjects/Contact/003N0000004yF9jIAE"
      },
      "Id" : "003N0000004yF9jIAE",
      "Name" : "Merlin Jackz",
      "Email" : "testtt@gmail.com",
      "AccountId" : "001N0000005jCueIAE",
      "MailingStreet" : "SK VISTA, OLD Airport Road",
      "MailingCity" : "BANGALORE",
      "MailingPostalCode" : "560017",
      "MailingState" : "Karnataka",
      "MailingCountry" : "India",
      "Location__Latitude__s" : 12.9563586,
      "Location__Longitude__s" : 77.6488153,
      "CurrencyIsoCode" : "USD",
      "Account" : {
        "attributes" : {
          "type" : "Account",
          "url" : "/services/data/v34.0/sobjects/Account/001N0000005jCueIAE"
        },
        "Name" : "Account3",
        "Id" : "001N0000005jCueIAE",
        "RecordTypeId" : "01290000000Rw2LAAS",
        "CurrencyIsoCode" : "USD"
      }
    }, {
      "attributes" : {
        "type" : "Contact",
        "url" : "/services/data/v34.0/sobjects/Contact/003N000000Ibpy8IAB"
      },
      "Id" : "003N000000Ibpy8IAB",
      "Name" : "loop holes",
      "Email" : "jkarthika.ram@gmail.com",
      "AccountId" : "001N000000EaKJkIAN",
      "MailingStreet" : "NO.1,LS TRANQUIL Appartments\r\nSR LAYOUT ,MURUGESHPALYA",
      "MailingCity" : "bangalore",
      "MailingPostalCode" : "560017",
      "MailingCountry" : "India",
      "CurrencyIsoCode" : "CAD",
      "Account" : {
        "attributes" : {
          "type" : "Account",
          "url" : "/services/data/v34.0/sobjects/Account/001N000000EaKJkIAN"
        },
        "Name" : "Test Nicomatic1",
        "Id" : "001N000000EaKJkIAN",
        "RecordTypeId" : "01290000000Rw2LAAS",
        "CurrencyIsoCode" : "CAD"
      }
    }, {
      "attributes" : {
        "type" : "Contact",
        "url" : "/services/data/v34.0/sobjects/Contact/003N0000005SJZtIAO"
      },
      "Id" : "003N0000005SJZtIAO",
      "Name" : "Alex",
      "Email" : "alexis.delassat@gmail.com",
      "AccountId" : "001N0000005k1OkIAI",
      "MailingStreet" : "fdbdgbdb\r\ncbgvdgfhgfhd",
      "MailingCity" : "nellore",
      "MailingPostalCode" : "560017",
      "MailingState" : "Andhra Pradesh",
      "MailingCountry" : "India",
      "CurrencyIsoCode" : "USD",
      "Account" : {
        "attributes" : {
          "type" : "Account",
          "url" : "/services/data/v34.0/sobjects/Account/001N0000005k1OkIAI"
        },
        "Name" : "TestAdd",
        "Id" : "001N0000005k1OkIAI",
        "RecordTypeId" : "01290000000Rw2LAAS",
        "CurrencyIsoCode" : "USD"
      }
    }, {
      "attributes" : {
        "type" : "Account",
        "url" : "/services/data/v34.0/sobjects/Account/001N000000NIOLWIA5"
      },
      "Id" : "001N000000NIOLWIA5",
      "Name" : "KVP BANGALORE",
      "BillingState" : "Karnataka",
      "BillingCountry" : "India",
      "RecordTypeId" : "01290000000Rw2LAAS",
      "CurrencyIsoCode" : "CAD",
      "Location__Latitude__s" : 57.4755555,
      "Location__Longitude__s" : -132.3597222
    }, {
      "attributes" : {
        "type" : "Account",
        "url" : "/services/data/v34.0/sobjects/Account/001N0000009O05HIAS"
      },
      "Id" : "001N0000009O05HIAS",
      "Name" : "gsad12345",
      "BillingCountry" : "France",
      "RecordTypeId" : "01290000000Rw2LAAS",
      "CurrencyIsoCode" : "USD",
      "Location__Latitude__s" : 57.4755555,
      "Location__Longitude__s" : -132.3597222
    }, {
      "attributes" : {
        "type" : "Account",
        "url" : "/services/data/v34.0/sobjects/Account/001N000000U5duZIAR"
      },
      "Id" : "001N000000U5duZIAR",
      "Name" : "Test company 1",
      "BillingStreet" : "SR LAYOUT",
      "BillingCity" : "bangalore",
      "BillingPostalCode" : "560017",
      "BillingState" : "Karnataka",
      "BillingCountry" : "India",
      "RecordTypeId" : "01290000000Rw2LAAS",
      "CurrencyIsoCode" : "CAD",
      "Location__Latitude__s" : 12.9546824,
      "Location__Longitude__s" : 77.65039089999999
    }, {
      "attributes" : {
        "type" : "Account",
        "url" : "/services/data/v34.0/sobjects/Account/001N000000M3ZSjIAN"
      },
      "Id" : "001N000000M3ZSjIAN",
      "Name" : "UNKNOWN",
      "BillingCity" : "bangalore",
      "BillingPostalCode" : "560017",
      "BillingCountry" : "France",
      "RecordTypeId" : "01290000000Rw2LAAS",
      "CurrencyIsoCode" : "CAD",
      "Location__Latitude__s" : 12.9715987,
      "Location__Longitude__s" : 77.5945627
    }, {
      "attributes" : {
        "type" : "Account",
        "url" : "/services/data/v34.0/sobjects/Account/001N000000XXoorIAD"
      },
      "Id" : "001N000000XXoorIAD",
      "Name" : "Mallya Hospital",
      "BillingStreet" : "No. 2, Vittal Mallya Road",
      "BillingCity" : "Bangalore",
      "BillingPostalCode" : "560001",
      "BillingState" : "Karnataka",
      "BillingCountry" : "India",
      "Location__Latitude__s" : 12.9679749,
      "Location__Longitude__s" : 77.595018,
      "RecordTypeId" : "01290000000Rw2LAAS",
      "CurrencyIsoCode" : "EUR"
    }, {
      "attributes" : {
        "type" : "Account",
        "url" : "/services/data/v34.0/sobjects/Account/001N0000005jCueIAE"
      },
      "Id" : "001N0000005jCueIAE",
      "Name" : "Account3",
      "BillingStreet" : "13th street",
      "BillingCity" : "Bangalore",
      "BillingPostalCode" : "3434",
      "BillingState" : "Karnataka",
      "BillingCountry" : "India",
      "RecordTypeId" : "01290000000Rw2LAAS",
      "CurrencyIsoCode" : "USD",
      "Location__Latitude__s" : 28.2460347,
      "Location__Longitude__s" : -81.2947529
    }, {
      "attributes" : {
        "type" : "Account",
        "url" : "/services/data/v34.0/sobjects/Account/001N000000L09rQIAR"
      },
      "Id" : "001N000000L09rQIAR",
      "Name" : "ChrisMilliz with Rep",
      "BillingCountry" : "Australia",
      "Location__Latitude__s" : 30.4566045,
      "Location__Longitude__s" : -83.9002349,
      "RecordTypeId" : "01290000000Rw2LAAS",
      "CurrencyIsoCode" : "EUR"
    }, {
      "attributes" : {
        "type" : "Account",
        "url" : "/services/data/v34.0/sobjects/Account/001N000000U5bjCIAR"
      },
      "Id" : "001N000000U5bjCIAR",
      "Name" : "UNKNOWN",
      "BillingCity" : "bangalore",
      "BillingPostalCode" : "560017",
      "BillingState" : "Karnataka",
      "BillingCountry" : "India",
      "Location__Latitude__s" : 12.9715987,
      "Location__Longitude__s" : 77.5945627,
      "RecordTypeId" : "01290000000Rw2LAAS",
      "CurrencyIsoCode" : "CAD"
    }, {
      "attributes" : {
        "type" : "Account",
        "url" : "/services/data/v34.0/sobjects/Account/001N000000XXopfIAD"
      },
      "Id" : "001N000000XXopfIAD",
      "Name" : "BGS Global Hospitals",
      "BillingStreet" : "26/1, Brigade Gateway,Beside Metro, Malleswaram West",
      "BillingCity" : "Bangalore",
      "BillingPostalCode" : "560055",
      "BillingState" : "Karnataka",
      "BillingCountry" : "India",
      "RecordTypeId" : "01290000000Rw2LAAS",
      "CurrencyIsoCode" : "EUR"
    }, {
      "attributes" : {
        "type" : "Account",
        "url" : "/services/data/v34.0/sobjects/Account/001N000000NIMxrIAH"
      },
      "Id" : "001N000000NIMxrIAH",
      "Name" : "Bisht Group",
      "BillingCity" : "Bangalore",
      "BillingState" : "Karnataka",
      "BillingCountry" : "India",
      "Location__Latitude__s" : 12.9715987,
      "Location__Longitude__s" : 77.5945627,
      "RecordTypeId" : "01290000000Rw2LAAS",
      "CurrencyIsoCode" : "CAD"
    }, {
      "attributes" : {
        "type" : "Account",
        "url" : "/services/data/v34.0/sobjects/Account/001N0000008BKnaIAG"
      },
      "Id" : "001N0000008BKnaIAG",
      "Name" : "service test",
      "BillingStreet" : "fewfdwwde",
      "BillingCity" : "fr",
      "BillingPostalCode" : "323323",
      "BillingCountry" : "France",
      "RecordTypeId" : "01290000000Rw2LAAS",
      "CurrencyIsoCode" : "USD"
    }, {
      "attributes" : {
        "type" : "Account",
        "url" : "/services/data/v34.0/sobjects/Account/001N000000XXolYIAT"
      },
      "Id" : "001N000000XXolYIAT",
      "Name" : "Fortis Hospital",
      "BillingStreet" : "154/9, Bannerghatta Road, Opposite IIM-B",
      "BillingCity" : "Bangalore",
      "BillingPostalCode" : "560076",
      "BillingState" : "Karnataka",
      "BillingCountry" : "India",
      "RecordTypeId" : "01290000000Rw2LAAS",
      "CurrencyIsoCode" : "EUR"
    }, {
      "attributes" : {
        "type" : "Account",
        "url" : "/services/data/v34.0/sobjects/Account/001N000000XXontIAD"
      },
      "Id" : "001N000000XXontIAD",
      "Name" : "HOSMAT Hospital",
      "BillingStreet" : "HOSMAT Hospital, 45 Magrath Road,Off Richmond Road",
      "BillingCity" : "Bangalore",
      "BillingPostalCode" : "560025",
      "BillingState" : "Karnataka",
      "BillingCountry" : "India",
      "RecordTypeId" : "01290000000Rw2LAAS",
      "CurrencyIsoCode" : "EUR",
      "Location__Latitude__s" : 12.9690342,
      "Location__Longitude__s" : 77.6134605
    }, {
      "attributes" : {
        "type" : "Account",
        "url" : "/services/data/v34.0/sobjects/Account/001N0000008CIMCIA4"
      },
      "Id" : "001N0000008CIMCIA4",
      "Name" : "673527et",
      "BillingStreet" : "muuuuuuuuuuuuuuuuuuuuuuu",
      "BillingCity" : "bangalore",
      "BillingPostalCode" : "560017",
      "BillingCountry" : "Costa Rica",
      "RecordTypeId" : "01290000000Rw2LAAS",
      "CurrencyIsoCode" : "EUR"
    }, {
      "attributes" : {
        "type" : "Account",
        "url" : "/services/data/v34.0/sobjects/Account/001N0000006FOnEIAW"
      },
      "Id" : "001N0000006FOnEIAW",
      "Name" : "Devfisher test account",
      "BillingStreet" : "11th",
      "BillingCity" : "bangalore",
      "BillingPostalCode" : "560068",
      "BillingState" : "Karnataka",
      "BillingCountry" : "India",
      "Location__Latitude__s" : 30.4465758,
      "Location__Longitude__s" : 30.321539,
      "RecordTypeId" : "01290000000Rw2LAAS",
      "CurrencyIsoCode" : "USD"
    }, {
      "attributes" : {
        "type" : "Account",
        "url" : "/services/data/v34.0/sobjects/Account/001N000000Kz7LSIAZ"
      },
      "Id" : "001N000000Kz7LSIAZ",
      "Name" : "Account Christine No Sales Assistant",
      "BillingCountry" : "Antarctica",
      "Location__Latitude__s" : 30.4566045,
      "Location__Longitude__s" : -83.9002349,
      "RecordTypeId" : "01290000000Rw2LAAS",
      "CurrencyIsoCode" : "EUR"
    }, {
      "attributes" : {
        "type" : "Lead",
        "url" : "/services/data/v34.0/sobjects/Lead/00QN0000002oZROMA2"
      },
      "Id" : "00QN0000002oZROMA2",
      "Name" : "Bangalore Central",
      "Street" : "Trinity Circle, Swami Vivekananda Road, Opp. Vivanta By Taj,",
      "City" : "Bangalore",
      "PostalCode" : "560008",
      "State" : "Karnataka",
      "Country" : "India",
      "CurrencyIsoCode" : "EUR"
    }, {
      "attributes" : {
        "type" : "Lead",
        "url" : "/services/data/v34.0/sobjects/Lead/00QN0000002F2hEMAS"
      },
      "Id" : "00QN0000002F2hEMAS",
      "Name" : "Edward Wiercinski",
      "Email" : "ewiercinski@horinc.com",
      "City" : "bangalore",
      "PostalCode" : "560017",
      "State" : "Karnataka",
      "Country" : "India",
      "Location__Latitude__s" : 50.9497222,
      "Location__Longitude__s" : -126.7505555,
      "CurrencyIsoCode" : "CAD"
    }, {
      "attributes" : {
        "type" : "Lead",
        "url" : "/services/data/v34.0/sobjects/Lead/00QN0000002oZRdMAM"
      },
      "Id" : "00QN0000002oZRdMAM",
      "Name" : "Esteem Mall",
      "Street" : "SY NO 127/128, HEBBAL,",
      "City" : "Bangalore",
      "PostalCode" : "560024",
      "State" : "Karnataka",
      "Country" : "India",
      "Location__Latitude__s" : 12.95816,
      "Location__Longitude__s" : 77.57763,
      "CurrencyIsoCode" : "EUR"
    }, {
      "attributes" : {
        "type" : "Lead",
        "url" : "/services/data/v34.0/sobjects/Lead/00QN0000002oZQpMAM"
      },
      "Id" : "00QN0000002oZQpMAM",
      "Name" : "Garuda Mall",
      "Street" : "15, Magrath Rd, Ashok Nagar",
      "City" : "Bangalore",
      "PostalCode" : "560025",
      "State" : "Karnataka",
      "Country" : "India",
      "Location__Latitude__s" : 12.9699772,
      "Location__Longitude__s" : 77.6098426,
      "CurrencyIsoCode" : "EUR"
    }, {
      "attributes" : {
        "type" : "Lead",
        "url" : "/services/data/v34.0/sobjects/Lead/00QN0000002oZQaMAM"
      },
      "Id" : "00QN0000002oZQaMAM",
      "Name" : "The Forum",
      "Street" : "No. 21, Hosur Road, Koramangala,",
      "City" : "Bangalore",
      "PostalCode" : "560095",
      "State" : "Karnataka",
      "Country" : "India",
      "Location__Latitude__s" : 12.9344611,
      "Location__Longitude__s" : 77.61136239999999,
      "CurrencyIsoCode" : "EUR"
    } ]

我想过滤我的jsonstring:

检查属性的条件:“Location__Latitude__s”“Location__Longitude__s” 条件不等于null:

然后

{
      "attributes" : {
         "type" : "contact",
         "Name" : "Infosys LTd.",
        "Location_Latitude__s" : 12.954614,
        "Location__Longitude__s" : 77.648959,
        },
       {
       },

我在JSON过滤方面做得不多, 我正在学习! 请帮我这样做。

2 个答案:

答案 0 :(得分:0)

json是您原来的json对象

    var filter = [];
    for(o in json){
        if(json[o].Location__Latitude__s && json[o].Location__Longitude__s){
            var temp = {"attributes":{
                "type" : json[o].attributes.type,
                "Name" : json[o].Name,
                "Location_Latitude__s" : json[o].Location__Latitude__s,
                "Location__Longitude__s" : json[o].Location__Longitude__s,
            }}
            filter.push(temp);
        }
    }
    console.log(filter);

答案 1 :(得分:0)

var obj = JSON.parse(jsonString);  
for(i=0;i<obj.length;i++){ 
  if(Object[i].Location__Latitude__s==null){ do whatever you want to do with it }
  if(Object[i].Location__Longitude__s==null){ do whatever you want to do with it }
}