json_test.go 633 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package test
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "testing"
  6. )
  7. func Test_json(t *testing.T) {
  8. articleStrings := `{
  9. "clientID": "869023065073597",
  10. "msgID": "24152",
  11. "paramsb": {
  12. "typeCode": "123",
  13. "typeCode2": "123"
  14. },
  15. "paramslist": [{
  16. "typeCode": "123",
  17. "typeCode2": "123"
  18. }],
  19. "params": [{
  20. "typeCode": "123",
  21. "typeCode2": "123",
  22. "varData": [{
  23. "name": "TempSet",
  24. "value": "27"
  25. }]
  26. }]
  27. }`
  28. var articleSlide map[string]interface{}
  29. multiErr := json.Unmarshal([]byte(articleStrings), &articleSlide)
  30. if multiErr != nil {
  31. fmt.Println("转换出错:", multiErr)
  32. }
  33. println("articleSlide:", articleSlide)
  34. }