Skip to content

kaushalmodi/p4ztag_to_json

Repository files navigation

P4 Ztag to JSON

https://github.com/kaushalmodi/p4ztag_to_json/actions/workflows/test.yml/badge.svg https://github.com/kaushalmodi/p4ztag_to_json/actions/workflows/docs.yml/badge.svg

Little utility to convert the Perforce P4 “Ztag” format data to JSON.

Command line

Pass a ztag format text file

p4ztag_to_json <ztagfile1.foo> <ztagfile2.bar> ..
# Generates <ztagfile1.json> <ztagfile2.json> ..

Pipe output of a p4 -ztag .. command to p4ztag_to_json

p4 -ztag info | p4ztag_to_json
# Prints JSONified version of that input to stdout

Sample “ztag” data

... depotFile //ydf/yepba/ik/LEMHT/uopd/tr/ofvd/ai_rgl.ng
... rev0 35
... change0 587347
... action0 mdlo
... type0 rkwr
... time0 1778604642
... user0 vtsoq
... client0 nq:awjyr:xrjmh.cyo:3724802i
... fileSize0 73567
... digest0 R008427167X2MKRE116S1Q0WFA4OP01T
... desc0 fnny txoeb: qltuvf KNN HHJ3 gbdr ydwwcj axmdlinwff

- bqq_ljqujqav_ofnw   -> CCW_bv
- nea_hswpfmas_vawxny -> WJA_ny
- fse_hnpoqedk_jxf    -> VVM_xc

... how0,0    poxhsp oilq
... file0,0   //lwj/hfssq/tcjvrcxx/POFJK/lkucc6/ol/gudu/my/kakg/pn_doa.xq
... srev0,0   #ddpk
... erev0,0   #1
... rev1 52
... change1 111522
... action1 myqr
... type1 tkrt
... time1 1332615524
... user1 wpeun
... client1 hu:wedwm:psspa.udl:7045580a
... fileSize1 02622
... digest1 6TVK8T0SV0V8PY454H374KM17AA1K43T
... desc1 Rcrrtxhjv xgr fw_sutxg_nuifp ss ic bxm [QJM]

Llkr ta c fmdikgakkl xxohgh .. fusds xfd td_jurfh_ocxji vc bny fiw ftnlfvdw, lhddefunqh wobbo eluoultw fla fnqb jb peotcc.

Converted JSON

[
  {
    "depotFile": "//ydf/yepba/ik/LEMHT/uopd/tr/ofvd/ai_rgl.ng",
    "nested": [
      "nested0",
      "nested1"
    ],
    "nested0": {
      "rev": "35",
      "change": "587347",
      "action": "mdlo",
      "type": "rkwr",
      "time": "1778604642",
      "user": "vtsoq",
      "client": "nq:awjyr:xrjmh.cyo:3724802i",
      "fileSize": "73567",
      "digest": "R008427167X2MKRE116S1Q0WFA4OP01T",
      "desc": "fnny txoeb: qltuvf KNN HHJ3 gbdr ydwwcj axmdlinwff\n- bqq_ljqujqav_ofnw   -> CCW_bv\n- nea_hswpfmas_vawxny -> WJA_ny\n- fse_hnpoqedk_jxf    -> VVM_xc\n",
      "nested": [
        "nested0"
      ],
      "nested0": {
        "how": "   poxhsp oilq",
        "file": "  //lwj/hfssq/tcjvrcxx/POFJK/lkucc6/ol/gudu/my/kakg/pn_doa.xq",
        "srev": "  #ddpk",
        "erev": "  #1"
      }
    },
    "nested1": {
      "rev": "52",
      "change": "111522",
      "action": "myqr",
      "type": "tkrt",
      "time": "1332615524",
      "user": "wpeun",
      "client": "hu:wedwm:psspa.udl:7045580a",
      "fileSize": "02622",
      "digest": "6TVK8T0SV0V8PY454H374KM17AA1K43T",
      "desc": "Rcrrtxhjv xgr fw_sutxg_nuifp ss ic bxm [QJM]\nLlkr ta c fmdikgakkl xxohgh .. fusds xfd td_jurfh_ocxji vc bny fiw ftnlfvdw, lhddefunqh wobbo eluoultw fla fnqb jb peotcc."
    }
  }
]

References