从json提取/删除部分变量

时间:2019-11-13 20:44:06

标签: json

我有一个问题,我有一个大约40万行的json文件,我只需要删除文件中所有信息的一小部分即可

这里是前几行

{
 "BlockTypesData": [
    {
      "id": 0,
      "analyticsType": 0,
      "gradientId": null,
      "stringID": "ITEM_TYPE_AIR",
      "textureAtlas": null,
      "opaqueMeshingData": true,
      "baseTexturing": {
        "specialMaterial": false,
        "faceTextureIndices": [
          [
            0
          ],
          [
            0
          ],
          [
            0
          ],
          [
            0
          ],
          [
            0
          ],
          [
            0
          ]
        ],
        "randomTransform": false,
        "textureSelectionStyle": [
          0,
          0,
          0,
          0,
          0,
          0
        ]
      },
      "decalTexturing": [
        {
          "specialMaterial": false,
          "faceTextureIndices": [
            [],
            [],
            [],
            [],
            [],
            []
          ],
          "randomTransform": false,
          "textureSelectionStyle": [
            0,
            0,
            0,
            0,
            0,
            0
          ]
        }
      ],
      "decalTextures": [],
      "faceColorIndex": [
        [
          0,
          1
        ],
        [
          0,
          1
        ],
        [
          0,
          1
        ],
        [
          0,
          1
        ],
        [
          0,
          1
        ],
        [
          0,
          1
        ]
      ],
      "alpha": null,
      "name": "AIR",
      "flags": 524296,
      "category": null,
      "liquidReactions": [],
      "shape": 0,
      "transparency": 255,
      "mesh": null,
      "animations": null,
      "cropLight": false,
      "light": null,
      "particles": null,
      "effects": {
        "BLOCK_HIT": "block_default_hit",
        "BLOCK_PLACE": "block_default_place",
        "BLOCK_BROKE": "block_default_break",
        "BLOCK_TILLED": "block_default_tilled",
        "BLOCK_FERTILIZED": "block_default_fertilized",
        "BLOCK_HIT_NO_DAMAGE": "block_default_hit_no_damage",
        "BLOCK_REPAIR": "block_default_repair"
      },
      "soundMaterial": "default",
      "guiSoundMaterial": null,
      "lodBias": 0,
      "generateable": false,
      "allowPrefab": false,
      "generateSlopes": 0,
      "generationTop": 0,
      "basicColor": null,
    },
    {
      "id": 1,
      "analyticsType": 1,
      "gradientId": null,
      "stringID": "ITEM_TYPE_SOIL_SILTY_BASE",
      "textureAtlas": "blocks",
      "opaqueMeshingData": true,
      "baseTexturing": {
        "specialMaterial": false,
        "faceTextureIndices": [
          [
            70,
            71,
            72,
            73,
            74,
            75,
            76,
            77,
            78
          ],
          [
            70,
            71,
            72,
            73,
            74,
            75,
            76,
            77,
            78
          ],
          [
            79,
            80,
            81
          ],
          [
            79,
            80,
            81
          ],
          [
            79,
            80,
            81
          ],
          [
            79,
            80,
            81
          ]
        ],
        "randomTransform": false,
        "textureSelectionStyle": [
          4,
          4,
          5,
          5,
          5,
          5
        ]
      },
      "decalTexturing": [
        {
          "specialMaterial": false,
          "faceTextureIndices": [
            [],
            [],
            [],
            [],
            [],
            []
          ],
          "randomTransform": false,
          "textureSelectionStyle": [
            0,
            0,
            0,
            0,
            0,
            0
          ]
        }
      ],
      "decalTextures": [],
      "faceColorIndex": [
        [
          0,
          1
        ],
        [
          0,
          1
        ],
        [
          0,
          1
        ],
        [
          0,
          1
        ],
        [
          0,
          1
        ],
        [
          0,
          1
        ]
      ],
      "alpha": null,
      "name": "SOIL_SILTY_BASE",
      "flags": 1409418413,
      "category": null,
      "liquidReactions": [],
      "shape": 256,
      "transparency": 0,
      "mesh": null,
      "animations": null,
      "cropLight": false,
      "light": null,
      "particles": null,
      "effects": {
        "BLOCK_BROKE": "block_dirt_break",
        "BLOCK_HIT": "block_dirt_hit",
        "BLOCK_TILLED": "block_dirt_tilled",
        "BLOCK_PLACE": "block_dirt_place",
        "BLOCK_FERTILIZED": "block_default_fertilized",
        "BLOCK_HIT_NO_DAMAGE": "block_default_hit_no_damage",
        "BLOCK_REPAIR": "block_default_repair"
      },
      "soundMaterial": "soil_soft",
      "guiSoundMaterial": null,
      "lodBias": 1,
      "generateable": true,
      "allowPrefab": true,
      "generateSlopes": 1,
      "generationTop": 128,
      "basicColor": null,
      "rotateToFace": false,
      "maxBlendPriority": 5888,
      "hasShadeBlends": false,
      "changeTypeResult": 5,
      "inventoryRemap": 11584,
      "foliageSeed": null,
      "foliageDrops": null,
      "foliage": null,
      "treeFoliage": null,
      "crop": null,
      "supportsCrop": 3,
      "blockLOD": false,
      "hardness": 0,
      "fixedNumHitsToDestroy": 0,
      "fixedActionTime": 0,
      "maxWear": 0,
      "wearScale": 1,
      "attributeModifierBundles": [
        "Block Soil Initial"
      ],
      "applyStatusEffects": null,
      "categories": [
        "SOIL"
      ],
      "listOrder": 0,
      "listTypeName": "GUI_LIST_TYPE_SOILS",
      "friction": 1,
      "elasticity": 0,
      "fallDamageMultiplier": 0.72000002861022949,
      "onlyDuringTimeLimitedEvents": null
    },
    null,
    null,

 .....

 ]
}

我只需要所有信息:

  • id
  • 名称
  • 类别
  • maxWear

也许还有1或2个

如何将所需变量提取到新文件或删除现有文件中不需要的变量?

我从未使用过活动的json文件,但是我仅以此json文件的形式获得信息。 有人可以为此写一个脚本吗?

thx

0 个答案:

没有答案