MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / fromJson

Method fromJson

source/game/StarVersioningDatabase.cpp:46–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46VersionedJson VersionedJson::fromJson(Json const& source) {
47 // Old versions of VersionedJson used '__' to distinguish between actual
48 // content and versioned content, but this is no longer necessary or
49 // relevant.
50 auto id = source.optString("id").orMaybe(source.optString("__id"));
51 auto version = source.optUInt("version").orMaybe(source.optUInt("__version"));
52 auto content = source.opt("content").orMaybe(source.opt("__content"));
53 return {*id, (VersionNumber)*version, *content};
54}
55
56bool VersionedJson::empty() const {
57 return content.isNull();

Callers

nothing calls this directly

Calls 4

orMaybeMethod · 0.80
optStringMethod · 0.80
optUIntMethod · 0.80
optMethod · 0.45

Tested by

no test coverage detected