如何仅在特定位置将xml数据转换/复制粘贴到json文件?

时间:2018-09-26 06:49:32

标签: json xml

我想将特定数据从xml文件放置到json文件。

xml数据:

<annotation>
<folder>img</folder>
<filename>1.jpg</filename>
<path>/home/administrator/Downloads/labelImg-master/img/1.jpg</path>
<source>
    <database>Unknown</database>
</source>
<size>
    <width>1280</width>
    <height>720</height>
    <depth>3</depth>
</size>
<segmented>0</segmented>
<object>
    <name>Person1</name>
    <pose>Unspecified</pose>
    <truncated>0</truncated>
    <difficult>0</difficult>
    <bndbox>
        <xmin>1038.0</xmin>
        <ymin>139.0</ymin>
        <width>137.79452054794524</width>
        <height>354.027397260274</height>
    </bndbox>
</object>

JSON数据:

 {
    "Frame_count":2,

        "Objects_detected":6,
        output:[
        {
        "Objects_classname":"person1",
            "x_val":1038.09644,
            "y_val":139.41479,
            "width":137.0592,
            "height":354.4133
        },
        ],
   }

因此,在上面的xml示例中,我只想将xmin数据复制到json的x_val中,将ymin数据复制到json的y_val中,并且将width,height相同。

并命名为json的Object_classname。

我需要使用任何这种语言的c ++,python和c。

0 个答案:

没有答案
相关问题