Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 根据类型将JSON文件中的每一行更改为常量_C#_Json - Fatal编程技术网

C# 根据类型将JSON文件中的每一行更改为常量

C# 根据类型将JSON文件中的每一行更改为常量,c#,json,C#,Json,我有一个JSON文件,它表示一个职位公告。在这个JSON文件中,它描述了职位、薪资范围、发布客户机等内容。我想知道是否可以加载这个文件(通过file.ReadAllText),循环所有行,然后根据类型将JSON的每一行的值更改为常量。例如,如果遇到字符串,请更改为“Lorem Ipsum” 下面是我正在使用的JSON示例: { "value": [ { "id": "C17548AD-A7CA-44CC-9D25-1655B7FF101A", "job_id": "195747",

我有一个JSON文件,它表示一个职位公告。在这个JSON文件中,它描述了职位、薪资范围、发布客户机等内容。我想知道是否可以加载这个文件(通过file.ReadAllText),循环所有行,然后根据类型将JSON的每一行的值更改为常量。例如,如果遇到字符串,请更改为“Lorem Ipsum”

下面是我正在使用的JSON示例:

{
"value": [
{
  "id": "C17548AD-A7CA-44CC-9D25-1655B7FF101A",
  "job_id": "195747",
  "agency": "OFFICE OF LABOR RELATIONS",
  "posting_type": "Internal",
  "num_of_positions": 1,
  "business_title": "Computer Associate (Software)",
  "civil_service_title": "COMPUTER ASSOC (SOFTWARE)",
  "title_code_no": "13631",
  "level": "02",
  "salary_range_from": 63226,
  "salary_range_to": 88002,
  "salary_frequency": "Annual",
  "work_location": "40 Rector Street New York Ny",
  "division_work_unit": "Systems Development",
  "job_description": "Under general supervision with varying degrees of latitude of independent initiative and judgment, the position is responsible for the design, implementation, enhancement, and maintenance of computer applications, systems, database programming and/or related software functions; performing related systems work.  Will work with NYC Automated Personnel System (NYCAPS) Application that uses the PeopleSoft/Oracle SQL server.  Will work with Premium Accounting & Central Enrollment System (PACES) Application that uses mainframe ADABAS/NATURAL until the application is migrated completely to NYCAPS.  Will work with online and batch processing on mainframe until complete migration to NYCAPS.",
  "minimum_qual_requirements": "(1) A baccalaureate degree from an accredited college, including or supplemented by twenty-four (24) semester credits in computer science or a related computer field and one (1) year of satisfactory full-time computer software experience in computer systems development and analysis, applications programming, database administration, systems programming or data communications; or  (2) A four year high school diploma or its educational equivalent and five (5) years of full-time satisfactory computer software experience as described in “1†above; or  (3) A satisfactory combination of education and experience that is equivalent to ''1'' or ''2'' above. A college education may be substituted for up to two years of the required experience in ''2'' above on the basis that sixty (60) semester credits from an accredited college are equated to one year of experience. In addition, twenty-four (24) semester credits from an accredited college or graduate school in computer science or a related field, or a certificate of at least 625 hours in computer programming from an accredited technical school (post high school), may be substituted for one year of experience. However, all candidates who attempt to qualify under option “3†must have at least a four-year high school diploma or its educational equivalent and at least two years of satisfactory full-time computer software experience as described in “1†above.    To receive credit, all college credits in computer science or a related computer field and/or the certificate in computer programming must be listed in Section A.6 on page 2 of the Education and Experience Test Paper.    Some examples of unacceptable experience are: End users of a computer system, program or software package; experience in the areas of computer technical support, computer operations; data entry/data retrieval; pure quality assurance (QA) auditing and   analysis; hardware installation; help desk; teaching; telecommunications; experience in productivity software products (e.g. word processing, spreadsheet, presentation, and database software, etc.); superficial use of preprogrammed software without   complex programming, design and implementation.",
  "preferred_skills": "PeopleSoft/Oracle SQL ADABAS/NATURAL JCL,VM/TSO,MVS, CICS/VS Microsoft SQL Unix, VB.Net, C#, FoxPro is a plus Proficient in Microsoft Office",
  "additional_information": "",
  "to_apply": "To apply please submit your cover letter and resume electronically using one of the following methods:  City Employees: Apply through Employee Self Service (ESS) at www. nyc.gov/ess  All Other Applicants:  Go to www.nyc.gov/careers  SEARCH FOR JOB ID# 195747  Submission of a resume is not a guarantee that you will receive an interview.",
  "hours_per_shift": "",
  "recruitment_contact": "",
  "residency_requirement": "New York City Residency is not required for this position",
  "posting_date": "2015-05-29T07:00:00Z",
  "post_until": "2015-06-11T07:00:00Z",
  "posting_updated": "2015-05-29T07:00:00Z",
  "process_date": "2015-06-02T07:00:00Z",
  "geo_location": {
    "type": "Point",
    "coordinates": [ -74.1279859095812, 40.6359634548426 ]
  },
  "tags": []
 }
 ]}

如果遇到“业务标题”和“工作描述”中的字符串,则应将其更改为“Lorem Ipsum”。

要检查类型,请在循环中使用此行:
if(innerItemChild.FirstOrDefault()?.Type==JTokenType.String)


将其作为字符串文件打开,按行拆分,按:如果行上的第二个参数前面有“它是字符串,否则它不是…是的,这是绝对可能的。您的问题是什么?它看起来足够简单,可以使用
字符串。替换
内容。替换(@““business_title”“,@”“Lorem Ipsum”“)
。假设要替换字符串值(不清楚)并正在使用,请参阅。另请参阅。