Home > Article > Backend Development > json hex is converted to string
<code class="javascript">var cmd = ["0x02,0x03,0xB4,0xB4,0x00,0x06","0x00,0x02,0x6E,0x00,0x00,0x05","0x01,0x01,0x00,0x78,0x00,0x05","0x03,0x03,0x82,0x96,0x00,0x05"];</code>
<code class="javascript">var cmd1=[0x02, 0x03, 0xB4, 0xB4, 0xFF, 0xFF,0x02, 0x03, 0xB4, 0xB4, 0x00, 0x06,0x00, 0x02, 0x6E, 0x00, 0x00, 0x05,0x01, 0x01, 0x00, 0x78, 0x00, 0x05,0x03, 0x03, 0x82, 0x96, 0x00, 0x05];</code>
<code class="javascript">var test =["0x02,0x03,0xB4,0xB4,0x00,0x06","0x00,0x02,0x6E,0x00,0x00,0x05","0x01,0x01,0x00,0x78,0x00,0x05","0x03,0x03,0x82,0x96,0x00,0x05"];</code>
<code class="javascript">var cloud = [0x02, 0x03, 0xB4, 0xB4, 0xFF, 0xFF, 0x02, 0x03, 0xB4, 0xB4, 0x00, 0x06, 0x00, 0x02, 0x6E, 0x00, 0x00, 0x05, 0x01, 0x01, 0x00, 0x78, 0x00, 0x05, 0x03, 0x03, 0x82, 0x96, 0x00, 0x05 ];</code>
The code is as above
cmd is a hexadecimal code converted through PHP, but it has been turned into a string when obtained by JS.
I want to turn cmd into the same hexadecimal screenshot as cmd1. The blue part is the desired effect. The red part is Data content