title: converting hex string to an integer while preserving the format
body: <p>Title might be aids I don't really know what this process is called. Anyway basically I am using JSON to config my tool. (which is wrote in C++). but I want to configure key binds for GetAsyncKeyState but JSON doesn't support hex which I need for the virtual key codes. A solution for this is to use a string then convert it back to an int. However no method i have found does this properly.</p>
  <p>here's some pseudocode for the expected output</p>
  <pre><code>string str = &quot;0x01&quot;;
  
  int i = 0;
  
  // here i should be converted
  
  std::cout &lt;&lt; std::hex &lt;&lt; i &lt;&lt; std::endl; // this should output 0x01
  </code></pre>