(t *testing.T)
| 1869 | } |
| 1870 | |
| 1871 | func TestModifiersInMultipaths(t *testing.T) { |
| 1872 | AddModifier("case", func(json, arg string) string { |
| 1873 | if arg == "upper" { |
| 1874 | return strings.ToUpper(json) |
| 1875 | } |
| 1876 | if arg == "lower" { |
| 1877 | return strings.ToLower(json) |
| 1878 | } |
| 1879 | return json |
| 1880 | }) |
| 1881 | json := `{"friends": [ |
| 1882 | {"age": 44, "first": "Dale", "last": "Murphy"}, |
| 1883 | {"age": 68, "first": "Roger", "last": "Craig"}, |
| 1884 | {"age": 47, "first": "Jane", "last": "Murphy"} |
| 1885 | ]}` |
| 1886 | |
| 1887 | res := Get(json, `friends.#.{age,first|@case:upper}|@ugly`) |
| 1888 | exp := `[{"age":44,"@case:upper":"DALE"},{"age":68,"@case:upper":"ROGER"},{"age":47,"@case:upper":"JANE"}]` |
| 1889 | assert(t, res.Raw == exp) |
| 1890 | |
| 1891 | res = Get(json, `{friends.#.{age,first:first|@case:upper}|0.first}`) |
| 1892 | exp = `{"first":"DALE"}` |
| 1893 | assert(t, res.Raw == exp) |
| 1894 | |
| 1895 | res = Get(readmeJSON, `{"children":children|@case:upper,"name":name.first,"age":age}`) |
| 1896 | exp = `{"children":["SARA","ALEX","JACK"],"name":"Tom","age":37}` |
| 1897 | assert(t, res.Raw == exp) |
| 1898 | } |
| 1899 | |
| 1900 | func TestIssue141(t *testing.T) { |
| 1901 | json := `{"data": [{"q": 11, "w": 12}, {"q": 21, "w": 22}, {"q": 31, "w": 32} ], "sql": "some stuff here"}` |
nothing calls this directly
no test coverage detected
searching dependent graphs…