我尝试编译一个使用SSE2的intel提供的随机数生成器函数.如果我尝试编译以下代码:
/////////////////////////////////////////////////////////////////////////////
// The Software is provided "AS IS" and possibly with faults.
// Intel disclaims any and all warranties and guarantees, express, implied or
// otherwise, arising, with respect to the software delivered hereunder,
// including but not limited to the warranty of merchantability, the warranty
// of fitness for a particular purpose, and any warranty of non-infringement
// of the intellectual property rights of any third party.
// Intel neither assumes nor authorizes any person to assume for …Run Code Online (Sandbox Code Playgroud) 我正在尝试解组从Web服务获得的一些json数据.我已经简化了下面代码中显示的问题.我的问题是我可以在代码工作中制作版本(c).
我知道它适用于单个数字值,如"timestamp"所示,方法是在json注释中添加选项",string".但我无法弄清楚这是如何或是否适用于字符串编码数字的数组.(参见代码中列出的示例json中的"转换")
package main
import (
"encoding/json"
"fmt"
)
//version (a)
type JsonData1 struct {
TimeStamp uint64 `json:"timestamp,string"`
Conversions [][2]string `json:"conversions"`
}
//version (b)
type JsonData2 struct {
TimeStamp uint64 `json:"timestamp,string"`
Conversions [][2]json.Number `json:"conversions"`
}
//version (c)
type JsonData3 struct {
TimeStamp uint64 `json:"timestamp,string"`
Conversions [][2]float32 `json:"conversions"`
}
const incomingJson string = `{"timestamp": "1407178369", "conversions": [["1.021", "2.124"], ["2.432", "3.923"], ["3.234", "5.001"]]}`
func main() {
var data1 JsonData1
if err1 := json.Unmarshal([]byte(incomingJson), &data1); err1 != nil {
fmt.Println("Error unmarshaling with struct …Run Code Online (Sandbox Code Playgroud)