yuanhung yeh
2020-10-27 5b98e9857d5081c30fcef0206c38f384dc542514
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import xml.etree.ElementTree as ET
import json
 
class ParserMOI:
      """ A funny format convert """
      def findbyelement():
          return './string'
 
      def toJSON(xmlFromAPI):
          xmlelm= ET.fromstring(xmlFromAPI)
          #print('-------')
          #print(xmlelm)
          #print('->->') 
          result=xmlelm
          #print(result.text)
          return json.loads(result.text)
      # ss='{"count": "2", "pointArray": [{"x": "300431.466453", "y": "2765416.019419", "z": "13.650453"}, {"x": "300428.019514", "y": "2765415.408211", "z": "13.498476"}]}'
      def moiJsonToArray(moijson):
          resultArray=[]
          if 'pointArray' not in moijson:
              print('error!',moijson)
              return []
 
          allxyz=moijson.get('pointArray')
          
           
          for row in allxyz:
              resultArray.append([row['x'],row['y'],row['z']])
          return resultArray