6.7.36 TextConverter

6.7.36.1 Outline of the node

Converts any HARK  supported data type to JSON text of the string type.

6.7.36.2 Necessary files

No files are required.

6.7.36.3 Usage

When to use

This node is used to connect to a node (eg HarkDataStreamSender or HARK-Python’s PyCodeExecuter ) that can accept input of string type. This node can convert any type supported by HARK  as JSON text so, it can be handled easily when using it with JSON text understandable languages (eg Python, JavaScript etc). For example, in HARK-Python’s PyCodeExecuter node, you can easily convert to Python object by using 'import json' and 'json.load()' in your script which processes data received with string type. Note that although the output of many nodes existing in HARK  can be used as an input for this node, exception cases exists. This will be improved with future updates.

Typical connection

Figure 6.139 and 6.140 shows connection examples for the TextConverter .

The sample network in Figure 6.139 is a network that transmits the sound source localization result and separated sound using the HarkDataStreamSender node. node_HarkDataStreamSender_2 is a connection example in the case where the information being transmitted on node_HarkDataStreamSender_1 is transmitted after converting it to JSON text with the TextConverter node.

The sample network in Figure 6.140 is a network used to send the sound source localization result and separated sound to the HARK-Python’s PyCodeExecuter node.

\includegraphics[width=.9\textwidth ]{fig/modules/TextConverter-1}
Figure 6.139: Connection example of TextConverter to HarkDataStreamSender 

\includegraphics[width=.9\textwidth ]{fig/modules/TextConverter-2}
Figure 6.140: Connection example of TextConverter to HARK-Python’s PyCodeExecuter

6.7.36.4 Input-output and property of the node

Input

DATA

: any type. For the currently supported types, see the table 6.138. Any number of input terminals can be added. The name of the input terminal is used as the name of the output JSON object (key in map, hash, associative array etc).

Output

TEXT

: string type.

Parameter

Table 6.137: Parameter list of MatrixToMap 

Parameter name

Type

Default value

Unit

Description

ENABLE_DEBUG

bool 

false

 

Select whether to output the converted JSON text to standard output.

ENABLE_DEBUG

: bool type. The default value is false. Setting the value to true outputs the converted JSON text to the standard output.

6.7.36.5 Details of the node

Table 6.138: Conversion table of TextConverter 

INPUT

OUTPUT

input object type

output object type

input example

output result

bool 

string 

$ true $

{'DATA': true}

TrueObject 

string 

$ - $

{'DATA': true}

FalseObject 

string 

$ - $

{'DATA': false}

int 

string 

$ 1 $

{'DATA': 1}

Int 

string 

$ 1 $

{'DATA': 1}

float 

string 

$ 1.1 $

{'DATA': 1.1}

Float 

string 

$ 1.1 $

{'DATA': 1.1}

Complex 

string 

$ 1.1 - 2.2i $

{'DATA': (1.1, -2.2)}

Vector<int> 

string 

$ \left\langle \begin{array}{cccccc} 1 & -2 & 3 & -4 & 5 & -6 \end{array} \right\rangle $

{'DATA': [1, -2, 3, -4, 5, -6]}

Vector<float> 

string 

$ \left\langle \begin{array}{cccccc} 1.1 & -2.2 & 3.3 & -4.4 & 5.5 & -6.6 \end{array} \right\rangle $

{'DATA': [1.1, -2.2, 3.3, -4.4, 5.5, -6.6]}

Vector<complex<float> > 

string 

$ \left\langle \begin{array}{cccccc} 1.1 - 2.2i & 3.3 + 4.4i & -5.5 - 6.6i \end{array} \right\rangle $

{'DATA': [(1.1, -2.2), (3.3, 4.4), (-5.5, -6.6)]}

Matrix<int> 

string 

$ \left[ \begin{array}{cc} 1 & -2\\ -3 & 4\\ 5 & 6\\ \end{array} \right] $

{'DATA': [[1, -2], [-3, 4], [5, 6]]}

Matrix<float> 

string 

$ \left[ \begin{array}{cc} 1.1 & -2.2\\ -3.3 & 4.4\\ 5.5 & 6.6\\ \end{array} \right] $

{'DATA': [[1.1, -2.2], [-3.3, 4.4], [5.5, 6.6]]}

Matrix<complex<float> > 

string 

$ \left[ \begin{array}{cc} 1.1 - 2.2i & 3.3 + 4.4i\\ -5.5 + 6.6i & -7.7 - 8.8i\\ \end{array} \right] $

{'DATA': [[(1.1, -2.2), (3.3, 4.4)], [(-5.5, 6.6), (-7.7, -8.8)]]}

Map$<$int , Vector<int> $>$

string 

$ \left\{ 0, \left\langle \begin{array}{cccccc} 1 & -2 & 3 & -4 & 5 & -6 \end{array} \right\rangle \right\} $

{'DATA': {0: [1, -2, 3, -4, 5, -6]}}

Map$<$int , Vector<float> $>$

string 

$ \left\{ 0, \left\langle \begin{array}{cccccc} 1.1 & -2.2 & 3.3 & -4.4 & 5.5 & -6.6 \end{array} \right\rangle \right\} $

{'DATA': {0: [1.1, -2.2, 3.3, -4.4, 5.5, -6.6]}}

Map$<$int , Vector<complex<float> > $>$

string 

$ \left\{ 0, \left\langle \begin{array}{cccccc} 1.1 - 2.2i & 3.3 + 4.4i & 5.5 - 6.6i \end{array} \right\rangle \right\} $

{'DATA': {0: [(1.1, -2.2), (3.3, 4.4), (5.5, -6.6)]}}

Map$<$int , Matrix<int> $>$

string 

$ \left\{ 0, \left[ \begin{array}{cc} 1 & -2\\ -3 & 4\\ 5 & 6\\ \end{array} \right] \right\} $

{'DATA': {0: [[1, -2], [-3, 4], [5, 6]]}}

Map$<$int , Matrix<float> $>$

string 

$ \left\{ 0, \left[ \begin{array}{cc} 1.1 & -2.2\\ -3.3 & 4.4\\ 5.5 & 6.6\\ \end{array} \right] \right\} $

{'DATA': {0: [[1.1, -2.2], [-3.3, 4.4], [5.5, 6.6]]}}

Map$<$int , Matrix<complex<float> > $>$

string 

$ \left\{ 0, \left[ \begin{array}{cc} 1.1 - 2.2i & 3.3 + 4.4i\\ -5.5 + 6.6i & -7.7 - 8.8i\\ \end{array} \right] \right\} $

{'DATA': {0: [[(1.1, -2.2), (3.3, 4.4)], [(-5.5, 6.6), (-7.7, -8.8)]]}}