diff --git a/source/dub/compilers/utils.d b/source/dub/compilers/utils.d index 6cdff13..90cdbfb 100644 --- a/source/dub/compilers/utils.d +++ b/source/dub/compilers/utils.d @@ -378,9 +378,9 @@ auto json = parseJsonString(output); BuildPlatform build_platform; - build_platform.platform = json.platform.get!(Json[]).map!(e => e.get!string()).array(); - build_platform.architecture = json.architecture.get!(Json[]).map!(e => e.get!string()).array(); - build_platform.compiler = json.compiler.get!string; - build_platform.frontendVersion = json.frontendVersion.get!int; + build_platform.platform = json["platform"].get!(Json[]).map!(e => e.get!string()).array(); + build_platform.architecture = json["architecture"].get!(Json[]).map!(e => e.get!string()).array(); + build_platform.compiler = json["compiler"].get!string; + build_platform.frontendVersion = json["frontendVersion"].get!int; return build_platform; } diff --git a/source/dub/dependency.d b/source/dub/dependency.d index cbb5e2d..db60cfb 100644 --- a/source/dub/dependency.d +++ b/source/dub/dependency.d @@ -302,7 +302,7 @@ logDiagnostic("Ignoring version specification (%s) for path based dependency %s", pv.get!string, pp.get!string); dep = Dependency.any; - dep.path = Path(verspec.path.get!string); + dep.path = Path(verspec["path"].get!string); } else { enforce("version" in verspec, "No version field specified!"); auto ver = verspec["version"].get!string; diff --git a/source/dub/internal/vibecompat/data/json.d b/source/dub/internal/vibecompat/data/json.d index ece7d10..16a24d3 100644 --- a/source/dub/internal/vibecompat/data/json.d +++ b/source/dub/internal/vibecompat/data/json.d @@ -693,14 +693,6 @@ m_array ~= element; } - /** Scheduled for deprecation, please use `opIndex` instead. - - Allows to access existing fields of a JSON object using dot syntax. - */ - @property const(Json) opDispatch(string prop)() const { return opIndex(prop); } - /// ditto - @property ref Json opDispatch(string prop)() { return opIndex(prop); } - /** Compares two JSON values for equality. @@ -1422,8 +1414,8 @@ s.a = 2; auto j = serializeToJson(s); - assert(j.a.type == Json.Type.int_); - assert(j.b.type == Json.Type.null_); + assert(j["a"].type == Json.Type.int_); + assert(j["b"].type == Json.Type.null_); auto t = deserializeJson!S(j); assert(!t.a.isNull() && t.a == 2); @@ -1807,10 +1799,10 @@ unittest { auto a = Json.emptyObject; - a.a = Json.emptyArray; - a.b = Json.emptyArray; - a.b ~= Json(1); - a.b ~= Json.emptyObject; + a["a"] = Json.emptyArray; + a["b"] = Json.emptyArray; + a["b"] ~= Json(1); + a["b"] ~= Json.emptyObject; assert(a.toString() == `{"a":[],"b":[1,{}]}` || a.toString == `{"b":[1,{}],"a":[]}`); assert(a.toPrettyString() == diff --git a/source/dub/internal/vibecompat/data/serialization.d b/source/dub/internal/vibecompat/data/serialization.d index 6903a05..818739e 100644 --- a/source/dub/internal/vibecompat/data/serialization.d +++ b/source/dub/internal/vibecompat/data/serialization.d @@ -139,8 +139,8 @@ test.text = "Hello"; Json serialized = serialize!JsonSerializer(test); - assert(serialized.value.get!int == 12); - assert(serialized.text.get!string == "Hello"); + assert(serialized["value"].get!int == 12); + assert(serialized["text"].get!string == "Hello"); } unittest { @@ -243,8 +243,8 @@ } Json serialized = Json.emptyObject; - serialized.value = 12; - serialized.text = "Hello"; + serialized["value"] = 12; + serialized["text"] = "Hello"; Test test = deserialize!(JsonSerializer, Test)(serialized); assert(test.value == 12); diff --git a/source/dub/packagemanager.d b/source/dub/packagemanager.d index 199a979..c8399f9 100644 --- a/source/dub/packagemanager.d +++ b/source/dub/packagemanager.d @@ -338,7 +338,7 @@ /// destination and sets a version field in the package description. Package storeFetchedPackage(Path zip_file_path, Json package_info, Path destination) { - auto package_name = package_info.name.get!string; + auto package_name = package_info["name"].get!string; auto package_version = package_info["version"].get!string; auto clean_package_version = package_version[package_version.startsWith("~") ? 1 : 0 .. $]; @@ -527,8 +527,8 @@ enforce(packlist.type == Json.Type.array, LocalPackagesFilename~" must contain an array."); foreach( pentry; packlist ){ try { - auto name = pentry.name.get!string; - auto path = Path(pentry.path.get!string); + auto name = pentry["name"].get!string; + auto path = Path(pentry["path"].get!string); if (name == "*") { paths ~= path; } else { @@ -550,7 +550,7 @@ logWarn("Locally registered package %s %s was not found. Please run \"dub remove-local %s\".", name, ver, path.toNativeString()); auto info = Json.emptyObject; - info.name = name; + info["name"] = name; pp = new Package(info, path); } } @@ -631,7 +631,7 @@ if (existsFile(ovrfilepath)) { foreach (entry; jsonFromFile(ovrfilepath)) { PackageOverride ovr; - ovr.package_ = entry.name.get!string; + ovr.package_ = entry["name"].get!string; ovr.version_ = Dependency(entry["version"].get!string); if (auto pv = "targetVersion" in entry) ovr.targetVersion = Version(pv.get!string); if (auto pv = "targetPath" in entry) ovr.targetPath = Path(pv.get!string); @@ -678,8 +678,8 @@ Json[] newlist; foreach (p; m_repositories[type].searchPath) { auto entry = Json.emptyObject; - entry.name = "*"; - entry.path = p.toNativeString(); + entry["name"] = "*"; + entry["path"] = p.toNativeString(); newlist ~= entry; } @@ -702,10 +702,10 @@ Json[] newlist; foreach (ovr; m_repositories[type].overrides) { auto jovr = Json.emptyObject; - jovr.name = ovr.package_; + jovr["name"] = ovr.package_; jovr["version"] = ovr.version_.versionSpec; - if (!ovr.targetPath.empty) jovr.targetPath = ovr.targetPath.toNativeString(); - else jovr.targetVersion = ovr.targetVersion.toString(); + if (!ovr.targetPath.empty) jovr["targetPath"] = ovr.targetPath.toNativeString(); + else jovr["targetVersion"] = ovr.targetVersion.toString(); newlist ~= jovr; } auto path = m_repositories[type].packagePath; diff --git a/source/dub/project.d b/source/dub/project.d index a71b4f3..015cd01 100644 --- a/source/dub/project.d +++ b/source/dub/project.d @@ -1347,7 +1347,7 @@ if (j.type == Json.Type.string) return Dependency(Version(j.get!string)); else if (j.type == Json.Type.object) - return Dependency(Path(j.path.get!string)); + return Dependency(Path(j["path"].get!string)); else throw new Exception(format("Unexpected type for dependency: %s", j.type)); } @@ -1355,10 +1355,10 @@ const { Json json = serializeToJson(m_selections); Json serialized = Json.emptyObject; - serialized.fileVersion = FileVersion; - serialized.versions = Json.emptyObject; + serialized["fileVersion"] = FileVersion; + serialized["versions"] = Json.emptyObject; foreach (p, v; m_selections) - serialized.versions[p] = dependencyToJson(v.dep); + serialized["versions"][p] = dependencyToJson(v.dep); return serialized; } @@ -1367,7 +1367,7 @@ enforce(cast(int)json["fileVersion"] == FileVersion, "Mismatched dub.select.json version: " ~ to!string(cast(int)json["fileVersion"]) ~ "vs. " ~to!string(FileVersion)); clear(); scope(failure) clear(); - foreach (string p, v; json.versions) + foreach (string p, v; json["versions"]) m_selections[p] = Selected(dependencyFromJson(v)); } } diff --git a/source/dub/recipe/json.d b/source/dub/recipe/json.d index 5f1603b..a254e89 100644 --- a/source/dub/recipe/json.d +++ b/source/dub/recipe/json.d @@ -73,13 +73,13 @@ Json toJson(in ref PackageRecipe recipe) { auto ret = recipe.buildSettings.toJson(); - ret.name = recipe.name; + ret["name"] = recipe.name; if (!recipe.version_.empty) ret["version"] = recipe.version_; - if (!recipe.description.empty) ret.description = recipe.description; - if (!recipe.homepage.empty) ret.homepage = recipe.homepage; - if (!recipe.authors.empty) ret.authors = serializeToJson(recipe.authors); - if (!recipe.copyright.empty) ret.copyright = recipe.copyright; - if (!recipe.license.empty) ret.license = recipe.license; + if (!recipe.description.empty) ret["description"] = recipe.description; + if (!recipe.homepage.empty) ret["homepage"] = recipe.homepage; + if (!recipe.authors.empty) ret["authors"] = serializeToJson(recipe.authors); + if (!recipe.copyright.empty) ret["copyright"] = recipe.copyright; + if (!recipe.license.empty) ret["license"] = recipe.license; if (!recipe.subPackages.empty) { Json[] jsonSubPackages = new Json[recipe.subPackages.length]; foreach (i, subPackage; recipe.subPackages) { @@ -89,19 +89,19 @@ jsonSubPackages[i] = subPackage.recipe.toJson(); } } - ret.subPackages = jsonSubPackages; + ret["subPackages"] = jsonSubPackages; } if (recipe.configurations.length) { Json[] configs; foreach(config; recipe.configurations) configs ~= config.toJson(); - ret.configurations = configs; + ret["configurations"] = configs; } if (recipe.buildTypes.length) { Json[string] types; foreach (name, settings; recipe.buildTypes) types[name] = settings.toJson(); - ret.buildTypes = types; + ret["buildTypes"] = types; } if (!recipe.ddoxFilterArgs.empty) ret["-ddoxFilterArgs"] = recipe.ddoxFilterArgs.serializeToJson(); if (!recipe.ddoxTool.empty) ret["-ddoxTool"] = recipe.ddoxTool; @@ -151,8 +151,8 @@ private Json toJson(in ref ConfigurationInfo config) { auto ret = config.buildSettings.toJson(); - ret.name = config.name; - if (config.platforms.length) ret.platforms = serializeToJson(config.platforms); + ret["name"] = config.name; + if (config.platforms.length) ret["platforms"] = serializeToJson(config.platforms); return ret; } @@ -243,9 +243,9 @@ auto deps = Json.emptyObject; foreach( pack, d; bs.dependencies ) deps[pack] = serializeToJson(d); - ret.dependencies = deps; + ret["dependencies"] = deps; } - if (bs.systemDependencies !is null) ret.systemDependencies = bs.systemDependencies; + if (bs.systemDependencies !is null) ret["systemDependencies"] = bs.systemDependencies; if (bs.targetType != TargetType.autodetect) ret["targetType"] = bs.targetType.to!string(); if (!bs.targetPath.empty) ret["targetPath"] = bs.targetPath; if (!bs.targetName.empty) ret["targetName"] = bs.targetName;