Mercurial > hg > orthanc
comparison Core/DicomFormat/DicomMap.cpp @ 3005:8265a6b56100
DicomMap::FromDicomAsJson
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 12 Dec 2018 15:42:33 +0100 |
parents | da12ba232119 |
children | 0e1755e5efd0 |
comparison
equal
deleted
inserted
replaced
3004:80d1a3452807 | 3005:8265a6b56100 |
---|---|
980 return value->ParseDouble(result); | 980 return value->ParseDouble(result); |
981 } | 981 } |
982 } | 982 } |
983 | 983 |
984 | 984 |
985 void DicomMap::FromDicomAsJson(const Json::Value& dicomAsJson) | |
986 { | |
987 Clear(); | |
988 | |
989 Json::Value::Members tags = dicomAsJson.getMemberNames(); | |
990 for (Json::Value::Members::const_iterator | |
991 it = tags.begin(); it != tags.end(); ++it) | |
992 { | |
993 DicomTag tag(0, 0); | |
994 if (!DicomTag::ParseHexadecimal(tag, it->c_str())) | |
995 { | |
996 throw OrthancException(ErrorCode_CorruptedFile); | |
997 } | |
998 | |
999 const Json::Value& value = dicomAsJson[*it]; | |
1000 | |
1001 if (value.type() != Json::objectValue || | |
1002 !value.isMember("Type") || | |
1003 !value.isMember("Value") || | |
1004 value["Type"].type() != Json::stringValue) | |
1005 { | |
1006 throw OrthancException(ErrorCode_CorruptedFile); | |
1007 } | |
1008 | |
1009 if (value["Type"] == "String") | |
1010 { | |
1011 if (value["Value"].type() != Json::stringValue) | |
1012 { | |
1013 throw OrthancException(ErrorCode_CorruptedFile); | |
1014 } | |
1015 else | |
1016 { | |
1017 SetValue(tag, value["Value"].asString(), false /* not binary */); | |
1018 } | |
1019 } | |
1020 } | |
1021 } | |
1022 | |
1023 | |
985 void DicomMap::Serialize(Json::Value& target) const | 1024 void DicomMap::Serialize(Json::Value& target) const |
986 { | 1025 { |
987 target = Json::objectValue; | 1026 target = Json::objectValue; |
988 | 1027 |
989 for (Map::const_iterator it = map_.begin(); it != map_.end(); ++it) | 1028 for (Map::const_iterator it = map_.begin(); it != map_.end(); ++it) |