Получить объект JSON в текстовом файле с помощью PowerShell - PullRequest
0 голосов
/ 25 апреля 2018

У меня есть 1000 объектов JSON в текстовом файле. Я хочу получить только один объект JSON для определенного числа Дуна, используя PowerShell.

{
   "organization":{
      "duns":"024330410",
      "dunsControlStatus":{
         "operatingStatus":{
            "description":"Active",
            "dnbCode":9074
         },
         "isMarketable":false,
         "isMailUndeliverable":false,
         "isTelephoneDisconnected":null,
         "isDelisted":false,
         "subjectHandlingDetails":[

         ],
         "fullReportDate":"2018-02-10"
      },
      "primaryName":"SRP Trucking LLC",
      "multilingualPrimaryName":[

      ],
      "tradeStyleNames":[

      ],
      "websiteAddress":[

      ],
      "telephone":[

      ],
      "fax":[

      ],
      "primaryAddress":{
         "language":{

         },
         "addressCountry":{
            "name":"United States",
            "isoAlpha2Code":"US",
            "fipsCode":"US"
         },
         "continentalRegion":{
            "name":"North America"
         },
         "addressLocality":{
            "name":"LAKE HAVASU CITY"
         },
         "minorTownName":null,
         "addressRegion":{
            "name":"Arizona",
            "abbreviatedName":"AZ",
            "fipsCode":"04"
         },
         "addressCounty":{
            "name":"MOHAVE",
            "fipsCode":"015"
         },
         "postalCode":"864035343",
         "postalCodePosition":{

         },
         "streetNumber":null,
         "streetName":null,
         "streetAddress":{
            "line1":"25 SOUTHWESTER LN",
            "line2":null
         },
         "postOfficeBox":{

         },
         "latitude":34.488798,
         "longitude":-114.301529,
         "geographicalPrecision":{
            "description":"Street Address Centroid",
            "dnbCode":30257
         },
         "isRegisteredAddress":false,
         "isResidentialAddress":null,
         "statisticalArea":{
            "cbsaName":"Lake Havasu City-Kingman AZ",
            "cbsaCode":"29420",
            "economicAreaOfInfluenceCode":"092",
            "populationRank":{
               "rankNumber":"7",
               "rankDnBCode":10959,
               "rankDescription":"100,000 to 249,999"
            }
         },
         "locationOwnership":{

         },
         "premisesArea":{
            "measurement":2915.0,
            "unitDescription":"Square Foot",
            "unitDnBCode":3848,
            "reliabilityDescription":"Modelled",
            "reliabilityDnBCode":9094
         },
         "isManufacturingLocation":null
      },
      "multilingualPrimaryAddress":[

      ],
      "registeredAddress":{

      },
      "mailingAddress":{

      },
      "stockExchanges":[

      ],
      "thirdPartyAssessment":[

      ],
      "registrationNumbers":[

      ],
      "industryCodes":[
         {
            "code":"484110",
            "description":"General Freight Trucking, Local",
            "typeDescription":"North American Industry Classification System 2017",
            "typeDnBCode":30832,
            "priority":1
         },
         {
            "code":"1622",
            "description":"Trucking",
            "typeDescription":"D&B Hoovers Industry Code",
            "typeDnBCode":25838,
            "priority":1
         },
         {
            "code":"4212",
            "description":"Local trucking operator",
            "typeDescription":"US Standard Industry Code 1987 - 4 digit",
            "typeDnBCode":399,
            "priority":1
         },
         {
            "code":"42120000",
            "description":"Local trucking, without storage",
            "typeDescription":"D&B Standard Industry Code",
            "typeDnBCode":3599,
            "priority":1
         },
         {
            "code":"E",
            "description":"Transportation, Communications, Electric, Gas and Sanitary Services",
            "typeDescription":"D&B Standard Major Industry Code",
            "typeDnBCode":24657,
            "priority":1
         }
      ],
      "businessEntityType":{
         "description":"Unknown",
         "dnbCode":0
      },
      "controlOwnershipDate":"2015",
      "startDate":"2015",
      "controlOwnershipType":{

      },
      "isAgent":null,
      "isImporter":null,
      "isExporter":null,
      "numberOfEmployees":[
         {
            "value":1,
            "informationScopeDescription":"Consolidated",
            "informationScopeDnBCode":9067,
            "reliabilityDescription":"Modelled",
            "reliabilityDnBCode":9094,
            "employeeCategories":[

            ],
            "trend":[

            ]
         },
         {
            "value":1,
            "informationScopeDescription":"Individual",
            "informationScopeDnBCode":9066,
            "reliabilityDescription":"Modelled",
            "reliabilityDnBCode":9094,
            "employeeCategories":[

            ],
            "trend":[

            ]
         }
      ],
      "financials":[
         {
            "financialStatementToDate":"2016-10-01",
            "financialStatementDuration":null,
            "informationScopeDescription":null,
            "informationScopeDnBCode":null,
            "reliabilityDescription":"Modelled",
            "reliabilityDnBCode":9094,
            "unitCode":"Single Units",
            "accountantName":null,
            "yearlyRevenue":[
               {
                  "value":57815.0,
                  "currency":"USD",
                  "trend":[

                  ]
               }
            ]
         }
      ],
      "mostSeniorPrincipals":[
         {
            "givenName":"Debbie",
            "familyName":"Pickering",
            "fullName":"Debbie Pickering",
            "namePrefix":null,
            "nameSuffix":null,
            "gender":null,
            "jobTitles":[
               {
                  "title":"Owner"
               }
            ],
            "managementResponsibilities":[
               {
                  "description":"Owner",
                  "mrcCode":"A0A1"
               }
            ]
         }
      ],
      "currentPrincipals":[

      ],
      "socioEconomicInformation":{
         "isMinorityOwned":null,
         "isSmallBusiness":true
      },
      "isStandalone":true,
      "corporateLinkage":{

      }
   }
}

1 Ответ

0 голосов
/ 25 апреля 2018

PS направьте командлеты JSON, которые могут служить вашей цели:

Примите строку JSON в переменной как $ variable1 , затем используйте:

$variable1 | ConvertFrom-Json

и позже вы можете использовать Convertto-Json для преобразования этого в JSON также с where-object

Надеюсь, это поможет. Только что сформировал ответ от Томалака

...