弄了个 Mathematica 脚本方便将自己的本体数据写入原本的 masterParam, 本地数据按照 masterParam 的格式写即可。
masterParam=ImportString[FromCharacterCode@ToCharacterCode[Import["path\\49744fd6.txt"],"UTF-8"],"RawJSON"];
customParam=ImportString[FromCharacterCode@ToCharacterCode[Import["path\\customParam.txt"],"UTF-8"],"RawJSON"];
mergeParam[type_String]:=Block[
{list},
list=masterParam[[Key[type]]];
list=Join[list,customParam[[Key[type]]]];
list=Reverse[list];
list=DeleteDuplicatesBy[list,#iname&];
list=Reverse[list];
masterParam[[Key[type]]]=list;
]
mergeParam["Skill"];mergeParam["Buff"];mergeParam["Ability"];
Button["Export Master Param",
Export["path\\49744fd6.txt",masterParam,"RawJSON"];Print["OK!"]]
修改版
jsonOverwrite[json_, object_] := Module[
{pos, iname = object["iname"]},
pos = FirstPosition[json, _Association?(#["iname"] == iname &),
Null];
If[ListQ[pos], Part[json, (Sequence @@ pos)] = object,
Switch[StringSplit[iname, "_"][[1]],
"SK", AppendTo[json["Skill"], object],
"BUFF", AppendTo[json["Buff"], object],
"AB", AppendTo[json["Ability"], object]
]
]
]
SetAttributes[jsonOverwrite, HoldFirst]
网友评论