| ... | ... | @@ -70,7 +70,7 @@ pub fn server_fetchArray(url: string) ![]const Package { |
| 70 | 70 | errdefer list.deinit(); |
| 71 | 71 | |
| 72 | 72 | for (val.root.array.items) |item| { |
| 73 | | if (item.object.get("root_file").? == .null) continue; |
| 73 | if (get(item, "root_file") == null) continue; |
| 74 | 74 | try list.append(Package{ |
| 75 | 75 | .name = item.object.get("name").?.string, |
| 76 | 76 | .author = item.object.get("author").?.string, |
| ... | ... | @@ -100,8 +100,16 @@ fn valueLinks(vals: std.json.Value) ![]?string { |
| 100 | 100 | var list = std.ArrayList(?string).init(gpa); |
| 101 | 101 | errdefer list.deinit(); |
| 102 | 102 | |
| 103 | | if (vals.object.get("github")) |x| try list.append(x.string); |
| 104 | | if (vals.object.get("aquila")) |x| try list.append(x.string); |
| 105 | | if (vals.object.get("astrolabe")) |x| try list.append(x.string); |
| 103 | if (get(vals, "github")) |x| try list.append(x.string); |
| 104 | if (get(vals, "aquila")) |x| try list.append(x.string); |
| 105 | if (get(vals, "astrolabe")) |x| try list.append(x.string); |
| 106 | 106 | return list.toOwnedSlice(); |
| 107 | 107 | } |
| 108 | |
| 109 | fn get(obj: std.json, key: string) ?std.json.Value { |
| 110 | if (obj != .object) return; |
| 111 | const v = obj.object.get(key); |
| 112 | if (v == null) return null; |
| 113 | if (v == .null) return null; |
| 114 | return v; |
| 115 | } |