javascript - DCMTK dcm2json 会为损坏的 DS 或 IS 值生成无效的 JSON

标签 javascript node.js dicom dcmtk

DCMTK dcm2json 会为损坏的 DS 或 IS 值生成无效 JSON,请参阅 https://support.dcmtk.org/redmine/issues/769

JSON 将包含如下示例所示的值:

"00291003": {"vr":"IS","Value":[F]},

其中“F”显然不是数字。

最佳答案

这可以在 Nodejs 环境中解决,方法是首先通过以下方式运行原始的未解析的 JSON。

const jsonRepair = (rawJson) => {
    let regex1 =  /\[([^"]+)\]/g
    let isNumRegex = /^[-.0-9]*\d$/g
    let matches = undefined
    while ((matches = regex1.exec(rawJson)) !== null) {
        if (!isNumRegex.test(matches[1])) {
            rawJson = rawJson.replace(matches[0], `["${matches[1]}"]`)
            console.log(matches[0], `[${matches[1]}]`)
        }
    }
    return rawJson
}

关于javascript - DCMTK dcm2json 会为损坏的 DS 或 IS 值生成无效的 JSON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58035018/

相关文章:

javascript - 从另一个具有特定索引的数组创建

javascript - 如何关闭模态弹出窗口?

javascript - Node js 中服务器执行期间的内存状态

c++ - 未使用 ITK 正确读取 DICOM 图像系列

javascript - 如何安装CKeditor

javascript - 将鼠标滚轮/滚动事件从一个 div 转移到另一个 div

MySQL 从 html 中的 node.js 结果,通过 react.js

mongodb - node.js、mongoose 和 mongodb 安装起来很痛苦 :(

java - 寻找DICOM ECG查看器开源HTML5或任何基于Web的代码

c# - 将 jpg 图像作为 jpg 图像添加到 DICOM 文件