We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Go
go version go1.16.3 windows/amd64
GoFrame
v1.15.6
xml := `<?xml version="1.0" encoding="UTF-8"?> <result> <request> <response type="json"><![CDATA[{"data":[{"regionCode":"110000","regionName":"\u5317\u4EAC"}]}]]></response> </request> <request> <response type="json"><![CDATA[{"data":{"data":[{"storageCode":"001","storageName":"\u5317\u4EAC"}]}}]]></response> </request> </result>` a, _ := gparser.LoadContent(xml, true) b := a.MustToJson() c, _ := gjson.DecodeToJson(b) t.Log(1, c.GetString(".")) t.Log(2,c.GetString( "result.request.0.response.#text")) t.Log(3,c.GetString( "result.request.0.response.#text.data")) d := c.GetJson( "result.request.0.response.#text") t.Log(4, d.GetString("data"))
之前版本可以获取到的
json_test.go:25: 1 {"result":{"request":[{"response":{"#text":"{\"data\":[{\"regionCode\":\"110000\",\"regionName\":\"\\u5317\\u4EAC\"}]}","-type":"json"}},{"response":{"#text":"{\"data\":{\"data\":[{\"storageCode\":\"001\",\"storageName\":\"\\u5317\\u4EAC\"}]}}","-type":"json"}}]}} json_test.go:26: 2 {"data":[{"regionCode":"110000","regionName":"\u5317\u4EAC"}]} json_test.go:27: 3 json_test.go:30: 4 [{"regionCode":"110000","regionName":"北京"}]
The text was updated successfully, but these errors were encountered:
我试了1.14.x 1.15.x 1.16.x,CDATA里的字符串都不会直接解析未json对象。你需要先把其解析为json对象,然后再获取值,就像你的测试用例那样
d := c.GetJson( "result.request.0.response.#text") t.Log(4, d.GetString("data"))
Sorry, something went wrong.
No branches or pull requests
1. What version of
Go
and system type/arch are you using?go version go1.16.3 windows/amd64
2. What version of
GoFrame
are you using?v1.15.6
3. Can this issue be reproduced with the latest release?
4. What did you do?
5. What did you expect to see?
之前版本可以获取到的
6. What did you see instead?
The text was updated successfully, but these errors were encountered: