# HG changeset patch # User Sebastien Jodogne # Date 1681467154 -7200 # Node ID e5b0bd6b224270084fc12cc93e3d54372eaf055e # Parent 7cb1b851f5c8fa141fdc40bb36d3f42b4acf007f Added option "?numeric" if listing metadata diff -r 7cb1b851f5c8 -r e5b0bd6b2242 NEWS --- a/NEWS Fri Apr 14 11:49:24 2023 +0200 +++ b/NEWS Fri Apr 14 12:12:34 2023 +0200 @@ -17,6 +17,7 @@ * "/tools/find" now accepts the "Labels" and "LabelsConstraint" arguments * "/tools/labels" lists all the labels that are associated with any resource * "/system": added "UserMetadata" and "HasLabels" +* Added option "?numeric" if listing metadata Plugins ------- diff -r 7cb1b851f5c8 -r e5b0bd6b2242 OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp --- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Fri Apr 14 11:49:24 2023 +0200 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Fri Apr 14 12:12:34 2023 +0200 @@ -1679,6 +1679,8 @@ .SetUriArgument("id", "Orthanc identifier of the " + r + " of interest") .SetHttpGetArgument("expand", RestApiCallDocumentation::Type_String, "If present, also retrieve the value of the individual metadata", false) + .SetHttpGetArgument("numeric", RestApiCallDocumentation::Type_String, + "If present, use the numeric identifier of the metadata instead of its symbolic name", false) .AddAnswerType(MimeType_Json, "JSON array containing the names of the available metadata, " "or JSON associative array mapping metadata to their values (if `expand` argument is provided)") .SetHttpGetSample(GetDocumentationSampleResource(t) + "/metadata", true); @@ -1696,15 +1698,26 @@ Json::Value result; + bool isNumeric = call.HasArgument("numeric"); + if (call.HasArgument("expand")) { result = Json::objectValue; for (Metadata::const_iterator it = metadata.begin(); it != metadata.end(); ++it) { - std::string key = EnumerationToString(it->first); + std::string key; + if (isNumeric) + { + key = boost::lexical_cast(it->first); + } + else + { + key = EnumerationToString(it->first); + } + result[key] = it->second; - } + } } else { @@ -1712,7 +1725,14 @@ for (Metadata::const_iterator it = metadata.begin(); it != metadata.end(); ++it) { - result.append(EnumerationToString(it->first)); + if (isNumeric) + { + result.append(it->first); + } + else + { + result.append(EnumerationToString(it->first)); + } } }