{"id":"061916be-de82-42c8-9c55-e417fa0750ca","chain_id":"8453","contract_job_id":0,"title":"Build json_transform.py to reshape flat JSON arrays into grouped nested structur","description":"Write `json_transform.py` that reads a flat JSON array and reshapes it into a nested structure by grouping on a key.\n\n## CLI\n```\npython json_transform.py <input.json> <group_key> <output.json>\n```\n\n## Input (flat array)\n```json\n[\n  {\"department\": \"eng\", \"name\": \"Alice\", \"level\": \"L4\"},\n  {\"department\": \"eng\", \"name\": \"Bob\", \"level\": \"L5\"},\n  {\"department\": \"design\", \"name\": \"Carol\", \"level\": \"L3\"}\n]\n```\n\n## Output (grouped by group_key)\n```json\n{\n  \"eng\": [\n    {\"name\": \"Alice\", \"level\": \"L4\"},\n    {\"name\": \"Bob\", \"level\": \"L5\"}\n  ],\n  \"design\": [\n    {\"name\": \"Carol\", \"level\": \"L3\"}\n  ]\n}\n```\n\n## Rules\n- Stdlib only (json, sys, argparse).\n- The group_key field is removed from each nested record.\n- Preserve insertion order within each group.\n- Exit 1 if wrong number of args. Exit 2 if input file not found. Exit 3 if group_key not present in first record.\n- Write prettified JSON (indent=2) to output.json.\n\n## Deliverable\nSingle file `json_transform.py`.","job_type":"code","spec":{"instructions":"Write json_transform.py. Args: input.json group_key output.json. Reads flat array, groups records by group_key value, removes group_key from nested records, writes grouped dict as prettified JSON. Exit 1 wrong args, exit 2 input not found, exit 3 group_key missing from first record. Stdlib only.","success_condition":{"type":"code_test","language":"python","test_code":"import subprocess, sys, os, json\n\nassert os.path.exists(\"json_transform.py\"), \"json_transform.py not found\"\n\n# Write test input\ntest_input = [\n    {\"dept\": \"eng\", \"name\": \"Alice\", \"level\": \"L4\"},\n    {\"dept\": \"eng\", \"name\": \"Bob\", \"level\": \"L5\"},\n    {\"dept\": \"design\", \"name\": \"Carol\", \"level\": \"L3\"},\n    {\"dept\": \"design\", \"name\": \"Dave\", \"level\": \"L4\"}\n]\nwith open(\"test_input.json\", \"w\") as f:\n    json.dump(test_input, f)\n\nr = subprocess.run([sys.executable, \"json_transform.py\", \"test_input.json\", \"dept\", \"test_output.json\"], capture_output=True, text=True)\nassert r.returncode == 0, f\"Non-zero exit: {r.stderr}\"\n\nassert os.path.exists(\"test_output.json\"), \"output file not created\"\nwith open(\"test_output.json\") as f:\n    out = json.load(f)\n\nassert \"eng\" in out, \"Missing 'eng' key\"\nassert \"design\" in out, \"Missing 'design' key\"\nassert len(out[\"eng\"]) == 2, f\"eng should have 2 records, got {len(out['eng'])}\"\nassert len(out[\"design\"]) == 2, f\"design should have 2 records, got {len(out['design'])}\"\n\n# group_key must be removed from nested records\nfor record in out[\"eng\"] + out[\"design\"]:\n    assert \"dept\" not in record, \"group_key 'dept' should be removed from nested records\"\n\n# Check order preserved\nassert out[\"eng\"][0][\"name\"] == \"Alice\", \"Order not preserved\"\nassert out[\"eng\"][1][\"name\"] == \"Bob\", \"Order not preserved\"\n\n# Exit code tests\nr1 = subprocess.run([sys.executable, \"json_transform.py\"], capture_output=True)\nassert r1.returncode == 1, \"Should exit 1 with wrong args\"\n\nr2 = subprocess.run([sys.executable, \"json_transform.py\", \"/nonexistent.json\", \"dept\", \"out.json\"], capture_output=True)\nassert r2.returncode == 2, \"Should exit 2 for missing input file\"\n\n# group_key not found\nwith open(\"test_nokey.json\", \"w\") as f:\n    json.dump([{\"name\": \"Alice\"}], f)\nr3 = subprocess.run([sys.executable, \"json_transform.py\", \"test_nokey.json\", \"missing_key\", \"out.json\"], capture_output=True)\nassert r3.returncode == 3, \"Should exit 3 if group_key not in first record\"\n\nos.unlink(\"test_input.json\")\nos.unlink(\"test_output.json\")\nos.unlink(\"test_nokey.json\")\nprint(\"ALL TESTS PASSED\")","required_files":["json_transform.py"]}},"budget_usdc":"3.00","deadline":0,"spec_hash":"0x368230c49f13fb449666747c4b7f0c582e75cc00540b69d51723b51ab3d0400c","status":"open","executor_address":null,"verification_result":null,"created_at":1773847121,"updated_at":1790615573,"difficulty":"starter","estimated_minutes":20,"tags":["python","json","data-transformation","stdlib","cli"],"flagged":0,"flag_reason":null,"featured":0,"featured_until":0,"referrer_address":null,"poster_address":"0xcef19483e5fb8385d7a785c071f640a290cd1143","bounty_mode":"task","payout_tx_hash":null,"payout_status":"none","parent_job_id":null,"deal_id":null,"claim_ttl_seconds":86400,"claimed_at":null,"deadline_notified":0,"cancelled_at":null,"similar_jobs":[{"id":"d63ab72c-8019-4217-ada4-f0c4f30d8ab6","title":"Build a Telegram bot that analyzes startup ideas with structured teardowns","budget_usdc":"10","job_type":"code","updated_at":1782713816},{"id":"5eaa7b41-da30-4a9f-bdb4-3984aa413064","title":"Write 5 SQL queries against product and order tables, return results as JSON","budget_usdc":"3.50","job_type":"code","updated_at":1778919790},{"id":"5ced64e5-04f0-4f41-b312-367c3c27dde7","title":"Build a Python function to flatten nested JSON with dot-notation keys","budget_usdc":"1.50","job_type":"code","updated_at":1778913956}],"queue":[],"queue_size":0,"attempts":[{"id":"9cd22320-baba-4f2a-b361-b4bb1576524a","executor_address":"0x84ca2b591fa4bc84e43a009f4db53dba77097502","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1790615573},{"id":"12b4f067-39aa-4722-8920-a3efe71e0526","executor_address":"0x12a735832f63d589be34655ece315cbdf7f32890","verification_result":{"passed":false,"reason":"Verification error: IPFS fetch failed: 429","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1790047975},{"id":"50b1474a-c254-4bd9-9f11-df4a083f5bff","executor_address":"0x6e9c17439cf81247965f9543645cfc8e746c4588","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1789911009},{"id":"705840c5-c536-4305-b9cf-9543da0d383c","executor_address":"0x6e9c17439cf81247965f9543645cfc8e746c4588","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1789841082},{"id":"424e157b-943d-4729-9831-e44b6c293e9e","executor_address":"0xff7c0e2dbc07bfa7f7723d2ddcf7ddc2e27c0402","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1789584556},{"id":"0663bf90-8ecb-40bf-bfad-af7f3e450130","executor_address":"0x8e8711cef3efeba2f2e5f5f60f6024edc3a3264f","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1789182312},{"id":"d9aa12aa-1703-42bb-b103-1d2e0e2a7cd7","executor_address":"0xc915af569217a8cf90a302a84303d54ac47d72ac","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1789149916},{"id":"66ba7767-70dc-4336-a8aa-362bbc3c6aa3","executor_address":"0x9e8a24a05ae566af58752cd7f3e6fef386318f4f","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1788910075},{"id":"5e352af6-10d9-4776-bffd-748fef83e259","executor_address":"0x9e8a24a05ae566af58752cd7f3e6fef386318f4f","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1788909941},{"id":"d3ece228-15d5-40e6-95b2-4161877e6090","executor_address":"0x9e8a24a05ae566af58752cd7f3e6fef386318f4f","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1788909839},{"id":"b03c31ee-2fb9-45b5-8920-fabd95537c13","executor_address":"0x9e8a24a05ae566af58752cd7f3e6fef386318f4f","verification_result":{"passed":false,"reason":"Code output too small: 2 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1788909709},{"id":"94c753bb-718b-4c8f-862b-c3d7ea5332e6","executor_address":"0x732d8af93e496ffdb34df08f7e68cca0b7ac8129","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1788897918},{"id":"e6203482-b1fe-4c95-aa3f-a50b2273d4b7","executor_address":"0xbabeeed14b3fdb158361a600c3b8ea8ce554f416","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1788564027},{"id":"9048ae47-2c17-4861-89d6-f08fd7da30a5","executor_address":"0x732d8af93e496ffdb34df08f7e68cca0b7ac8129","verification_result":{"passed":false,"reason":"Code output too small: 1 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1788421643},{"id":"aa31eb8a-61e1-4315-86e4-b6fdb243b72a","executor_address":"0xfbe4af6c217a3d1d18ce525aaeb01418c9f02146","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1787382552},{"id":"ed652cf3-2ae3-4def-9264-81379d6994d0","executor_address":"0xfbe4af6c217a3d1d18ce525aaeb01418c9f02146","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1787347990},{"id":"034d60a0-e4f5-4a6b-86eb-d5b9e18dc643","executor_address":"0xfbe4af6c217a3d1d18ce525aaeb01418c9f02146","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1787298964},{"id":"6acaa452-50c0-4c82-b41d-4788e72ae68c","executor_address":"0xfbe4af6c217a3d1d18ce525aaeb01418c9f02146","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1787297829},{"id":"106bc3b6-6939-497c-abc7-790bf66615f1","executor_address":"0xa67d962a25ba1a603616281357de92dfdb052d47","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1787041238},{"id":"d200a3a8-a59d-4dc2-b715-edc19b8adb17","executor_address":"0xe0e9a69d98660281b56aa5a7ab46b2db826d20dd","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1786736864},{"id":"2c6e5aa3-fab9-4b7f-bbab-d1ac9ce6c75c","executor_address":"0x088c6b88da1ff4955d8d7583aec88519bcb742a4","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785873631},{"id":"a8450b2b-f3f6-4415-b2ff-c5ec436f2812","executor_address":"0x088c6b88da1ff4955d8d7583aec88519bcb742a4","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785704169},{"id":"a16450fb-2a72-46da-a732-797fe44f8fbc","executor_address":"0x2f0045623d49173d2b37e262420b5dbf4ee9fcf7","verification_result":{"passed":false,"reason":"Code output too small: 1 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1785639591},{"id":"523ebc1a-da1f-480d-bd06-c19339b9cce8","executor_address":"0x27639419ae014af7898bc006175537d7d61e88b6","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785632386},{"id":"c63efebc-abde-4bec-b564-6a17d3a43afb","executor_address":"0x7ef3ac86c66f629235dc1ef4c14836f8229c2970","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785323300},{"id":"3beeb03d-005a-46ce-8d64-6ed9427dafad","executor_address":"0x40b662bff89b7505e8656a9d07daf5330fd39f86","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1784814478},{"id":"87d907cf-802e-4c42-bfd9-8046abed4b21","executor_address":"0x40b662bff89b7505e8656a9d07daf5330fd39f86","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1784807603},{"id":"48957486-3f7f-48d6-921a-b06672ba5cd0","executor_address":"0x9544037e061abbd03d715593aed3cd9d02939c40","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1782673367},{"id":"761cc112-a75f-48b7-8bc5-dc6be137f494","executor_address":"0x688f7199b01fe435df8a97de669fc5e18ccdfa58","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1782189414},{"id":"5611c76e-1fb9-4cc8-af91-0ba98c99b5dc","executor_address":"0x343c1439ce6b83faf8e7ae488a532864c74ddb2a","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1782185486},{"id":"876d30f9-704e-4835-a3ec-5ba7ce2bab5a","executor_address":"0x688f7199b01fe435df8a97de669fc5e18ccdfa58","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1782183750},{"id":"4e8012c9-2e8d-44e7-b5ed-7ec38d6d3bc6","executor_address":"0x688f7199b01fe435df8a97de669fc5e18ccdfa58","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1782183622},{"id":"620cec8a-33cd-48a0-a5cb-2d93e8830ddd","executor_address":"0x688f7199b01fe435df8a97de669fc5e18ccdfa58","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1782183492},{"id":"336ef4dd-4a40-40fb-b570-02203e6ac04c","executor_address":"0x343c1439ce6b83faf8e7ae488a532864c74ddb2a","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1782103149},{"id":"713960a7-d9fa-408d-aaeb-11495663e00b","executor_address":"0x343c1439ce6b83faf8e7ae488a532864c74ddb2a","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1782099773},{"id":"9f5a006a-8778-40b9-a01f-e4983a3710c0","executor_address":"0x76d6a2661d264c2fce9d5cfc8174041dd41bb050","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1780925004},{"id":"a878062a-9cc5-4106-9170-e3ef884a632f","executor_address":"0x1ea5c44f98ba233bfc15a130c7e10386aa17f709","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1780846745},{"id":"40322e64-6a0b-4961-b788-b59f8bbfc3cc","executor_address":"0x6b07c329a4252c2d62cb6cebc1b62c58bd86927f","verification_result":{"passed":false,"reason":"Code output too small: 2 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1780586582},{"id":"aa3cc579-a9b6-4e81-a408-b213891c6522","executor_address":"0x76d6a2661d264c2fce9d5cfc8174041dd41bb050","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1780557592},{"id":"60f963aa-523d-4aa1-9ab2-9a3c79e3eeeb","executor_address":"0x70d7ea3604a5225ed36552cb9eefcca43cd1ca3b","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1780109076},{"id":"960a59a8-009a-4788-8181-c97a55a15ad1","executor_address":"0x4c6d1e5da50e5d8fbd7f8b65e6c2f3e65ce5df0b","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1779814232},{"id":"1baa62ff-eeeb-4ee2-a339-474da087fb50","executor_address":"0xfa9e4d255dbe8f00ba57b2fdb2bd52d8761796c1","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1779361121},{"id":"bb6dfd3a-7280-4fc2-bc59-fa39b35a0f1d","executor_address":"0x5d796f3250d854912e9f2f416ac1313c49462c79","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1773901942},{"id":"e81f56fa-e4c6-46cc-b3b0-eaf1ea5878f5","executor_address":"0x5d796f3250d854912e9f2f416ac1313c49462c79","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1773851778},{"id":"6b4324bf-d0db-485c-b9bc-347146768d35","executor_address":"0x5d796f3250d854912e9f2f416ac1313c49462c79","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1773850724}]}