The json hexadecimal format is converted to a string.

Source: Internet
Author: User
{Code ...} {code ...} {code ...} {code ...} the code above refers to the hexadecimal code obtained through PHP conversion. However, when JavaScript gets the code, it has become a string and you want to convert cmd to the hexadecimal Blue part like cmd1 for the desired effect. red indicates the data content.

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"];
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];
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"];
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 above

Cmd is a hexadecimal code obtained through PHP Conversion. However, when JavaScript is obtained, it has become a string.
To convert cmd to the hexadecimal blue part of cmd1, the desired result is red, which is the data content.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.