Skip to content

Commit d035d8b

Browse files
authored
Merge pull request #14428 from obsidiansystems/path-info-parse-json-cleanup
Clean up `PathInfo::fromJSON` using recent JSON utils changes
2 parents 4a2fb18 + 089a222 commit d035d8b

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/libstore/path-info.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -203,23 +203,23 @@ UnkeyedValidPathInfo UnkeyedValidPathInfo::fromJSON(const StoreDirConfig & store
203203

204204
// New format as this as nullable but mandatory field; handling
205205
// missing is for back-compat.
206-
if (json.contains("ca"))
207-
if (auto * rawCa = getNullable(valueAt(json, "ca")))
206+
if (auto * rawCa0 = optionalValueAt(json, "ca"))
207+
if (auto * rawCa = getNullable(*rawCa0))
208208
res.ca = ContentAddress::parse(getString(*rawCa));
209209

210-
if (json.contains("deriver"))
211-
if (auto * rawDeriver = getNullable(valueAt(json, "deriver")))
210+
if (auto * rawDeriver0 = optionalValueAt(json, "deriver"))
211+
if (auto * rawDeriver = getNullable(*rawDeriver0))
212212
res.deriver = store.parseStorePath(getString(*rawDeriver));
213213

214-
if (json.contains("registrationTime"))
215-
if (auto * rawRegistrationTime = getNullable(valueAt(json, "registrationTime")))
214+
if (auto * rawRegistrationTime0 = optionalValueAt(json, "registrationTime"))
215+
if (auto * rawRegistrationTime = getNullable(*rawRegistrationTime0))
216216
res.registrationTime = getInteger<time_t>(*rawRegistrationTime);
217217

218-
if (json.contains("ultimate"))
219-
res.ultimate = getBoolean(valueAt(json, "ultimate"));
218+
if (auto * rawUltimate = optionalValueAt(json, "ultimate"))
219+
res.ultimate = getBoolean(*rawUltimate);
220220

221-
if (json.contains("signatures"))
222-
res.sigs = getStringSet(valueAt(json, "signatures"));
221+
if (auto * rawSignatures = optionalValueAt(json, "signatures"))
222+
res.sigs = getStringSet(*rawSignatures);
223223

224224
return res;
225225
}

0 commit comments

Comments
 (0)