优化结构

This commit is contained in:
Yvan
2026-08-21 00:28:22 +08:00
parent 13f4589a18
commit d2fb5c11b8
13 changed files with 653 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
package paymentutil
import "testing"
func TestNestedAndPathValues(t *testing.T) {
object := JSONObject([]byte(`{"data":{"status":"SUCCESS","amount":100}}`))
if got := NestedString(object, "status"); got != "SUCCESS" {
t.Fatalf("NestedString = %q", got)
}
if got := StringAtPath(object, "data.amount"); got != "100" {
t.Fatalf("StringAtPath = %q", got)
}
if got := StringAtPath(object, "data.missing"); got != "" {
t.Fatalf("missing path = %q", got)
}
}