Home > Enterprise >  Update JSON object numbers in ascending order in sequence
Update JSON object numbers in ascending order in sequence

Time:01-19

I am having problem with my NFT JSON files. Because of lack of facilities I have generated my 10k NFT collection as 10*1000, now I have ten collections (each 1000) instead of a single collection (of 10000). The JSON objects of each collection are numbered from 1-1000. But I want to copy all JSON objects into a single file and update their "edition" numbers in sequence from 1-10000. Thanks in advance. Solution provider will be gifted 10 NFTs, also I have reserved ten NFTs for Daniel, aka HashLips, and ten for Petko Aleksandrov, and ten for another friend on stack overflow who provided another solution, yet I have not informed them for the gift. You can reach me on OpenSea as "Bellucci". Here is the NFT metadata code.

  "file_path": "ipfs://NewUriToReplace/1.png",
  "nft_name": "NFT #1",
  "external_link": "",
  "description": "NFT Description",
  "collection": "Collection Name",
  "properties": [
    {
      "type": "type",
      "name": "name"
    },
    {
      "type": "type",
      "name": "name"
    },
    {
      "type": "type",
      "name": "name"
    },
    {
      "type": "type",
      "name": "name"
    },
    {
      "type": "type",
      "name": "name"
    }
  ],
  "levels": [],
  "stats": [],
  "unlockable_content": [],
  "explicit_and_sensitive_content": false,
  "supply": 1,
  "blockchain": "Polygon",
  "price": 0.005,
  "quantity": 1,
  "dna": "a2fc94a3a51a7c853c01b553019628907f437d2a",
  "edition": 1,
  "date": 1642499902138,
  "creator": "Artist",
  "seller_fee_basis_points": 250,
  "address": "0x2c41a4e7d9321b1134b076bb0be866709fda6ffb",
  "share": 100,
  "Date": "January 2022",
  "compiler": "HashLips Art Engine"
}```

CodePudding user response:

You coud, for instance, use php where you have to read each file, append it to an array, edit the array then dump it to a file:

simple php code to deal with json

$arr = [];
//scroll trough files (you can use libraries to better do this)
for($i=0; $i<100;   i)
    array_push($arr, json_decode(file_get_contents("file$i.json"),true) );

//here $arr contains all the 100 jsons, you can access it as a normal associative array and you can
//do your stuff
$arr[100]['esition'] = 'my_edition';

//dump the associative array as to a single file formatted as json
file_put_contents("outfile.json",json_encode($arr));

CodePudding user response:

Found the solution through the HashLips art engine's main.js settings. If you want to generate your nft collection not in one step, but rather in many steps, for example 10*1000 instead of 10000. Make these on the HashLips Art Engine's main.js file's this part. In the third and seventh lines of this code replace 1 with starting number you want to start generating from. Here you can see I have replaced the 1s with 1001, so generation starts from 1001, not 1.

  let layerConfigIndex = 0;
  let editionCount = 1001;
  let failedCount = 0;
  let abstractedIndexes = [];
  for (
    let i = network == NETWORK.sol ? 0 : 1001;
    i <= layerConfigurations[layerConfigurations.length - 1].growEditionSizeTo;
    i  
  ) {
    abstractedIndexes.push(i);
  }```
  •  Tags:  
  • Related