dongzhan8001 2015-08-08 16:06 采纳率: 0%
浏览 47

如何在golang中将发布数据解析回原始格式?

Ok, i think this question is NOT a question in others web programming language like php, python.

but i met this question in golang and confused what is the best way to convert the post raw data back into it's original format.

and here is a sample.

1 original representation is an array consists of map:

photo[1][tags]{id: 1, direction:1, x: 1.0, y: 2, word: 'pull'}
photo[1][tags]{id: 2, direction:0, x: 2.0, y: 1.1, word: 'fi'}

process handler

func testPostData(w http.ResponseWriter, r *http.Request) error{
    r.ParseMultipartForm(10 << 20)
    data := r.ParseMultipartForm.Value
    fmt.Println(data)
}

**2** outputs in console
map[photo[1][tags][][direction]:[0]
    photo[1][tags][][word]:[fi]
    photo[1][tags][][x]:[1.1]
    photo[1][tags][][id]:[2]]

i'm a newbie to golang, so i think there is a way to help to convert data back to its original representation, here is convert 2 back to 1

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 目详情-五一模拟赛详情页
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line