Skip to content

Commit 40ab6a5

Browse files
committed
x.json2: remove x.json2.[decoder,decoder_deprecated].v
1 parent 0f52191 commit 40ab6a5

29 files changed

+101
-666
lines changed
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
vlib/v/checker/tests/comptime_selector_assign.vv:18:24: error: mismatched types: check field type with $if to avoid this problem
2-
16 | typ.$(field.name) = 2
3-
17 | }
4-
18 | typ.$(field.name) = 3
1+
vlib/v/checker/tests/comptime_selector_assign.vv:19:24: error: mismatched types: check field type with $if to avoid this problem
2+
17 | typ.$(field.name) = 2
3+
18 | }
4+
19 | typ.$(field.name) = 3
55
| ^
6-
19 | }
7-
20 | }
8-
vlib/v/checker/tests/comptime_selector_assign.vv:18:24: error: cannot assign to `typ.$(field.name)`: expected `string`, not `int literal`
9-
16 | typ.$(field.name) = 2
10-
17 | }
11-
18 | typ.$(field.name) = 3
6+
20 | }
7+
21 | }
8+
vlib/v/checker/tests/comptime_selector_assign.vv:19:24: error: cannot assign to `typ.$(field.name)`: expected `string`, not `int literal`
9+
17 | typ.$(field.name) = 2
10+
18 | }
11+
19 | typ.$(field.name) = 3
1212
| ^
13-
19 | }
14-
20 | }
13+
20 | }
14+
21 | }

vlib/v/checker/tests/comptime_selector_assign.vv

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import x.json2 { Any, raw_decode }
1+
import x.json2.decoder2 { decode }
2+
import x.json2 { Any }
23

34
struct Income {
45
mut:
@@ -22,7 +23,7 @@ pub fn structuring[T](res Any) T {
2223
}
2324

2425
fn main() {
25-
res := raw_decode('{
26+
res := decode[Any]('{
2627
"email": ["sdvsdv", "sds"],
2728
"code": 12
2829
}')!.as_map()
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import x.json2
2+
import x.json2.decoder2
23

34
fn main() {
45
x := '[[],[],[]]'
5-
println(json2.decode[json2.Any](x)!)
6+
println(decoder2.decode[json2.Any](x)!)
67
}

vlib/v/tests/aliases/alias_sumtype_method_call_test.v

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import x.json2
2+
import x.json2.decoder2
23

34
type MyType = json2.Any
45

@@ -8,7 +9,7 @@ struct Data {
89

910
fn test_alias_sumtype_method_call() {
1011
a := '{"a":"a","b":1}'
11-
json := json2.raw_decode(a) or { panic(err) }
12+
json := decoder2.decode[json2.Any](a) or { panic(err) }
1213
data := Data{json}
1314
json_str := data.prop.str()
1415
println(json_str)

vlib/v/tests/comptime/comptime_map_generic_test.v

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import x.json2
2+
import x.json2.decoder2
23

34
struct User {
45
pub mut:
@@ -7,7 +8,7 @@ pub mut:
78

89
fn test_main() {
910
user_json := '{"numbers":{"home":"123456","work":"987653"}}'
10-
res := json2.raw_decode(user_json)!.as_map()
11+
res := decoder2.decode[json2.Any](user_json)!.as_map()
1112

1213
mut numbers := map[string]string{}
1314
decode_map(mut numbers, res['numbers']!.as_map())!

vlib/v/tests/result_with_index_expr_test.v

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import x.json2
2+
import x.json2.decoder2
23

34
struct SomeStruct {
45
title string
@@ -11,7 +12,7 @@ fn test_result_with_index() {
1112
"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
1213
"body": "quia et suscipitsuscipit recusandae consequuntur expedita et cumreprehenderit molestiae ut ut quas totamnostrum rerum est autem sunt rem eveniet architecto"
1314
}'
14-
raw_data := json2.raw_decode(resp)!
15+
raw_data := decoder2.decode[json2.Any](resp)!
1516

1617
data := raw_data as map[string]json2.Any
1718

vlib/v/tests/skip_unused/generic_call_from_json.vv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import veb
22
import x.json2
3+
import x.json2.decoder2
34

45
pub struct Context {
56
veb.Context
@@ -11,7 +12,7 @@ pub struct App {
1112

1213
@['/'; POST]
1314
fn (app &App) index(mut ctx Context) veb.Result {
14-
j := json2.raw_decode(ctx.req.data) or { return ctx.request_error('error') }
15+
j := decoder2.decode[json2.Any](ctx.req.data) or { return ctx.request_error('error') }
1516

1617
m := j.as_map()
1718
myarr := m['myarr'] or { panic(error) }

vlib/veb/tests/handle_split_requests_in_chrome_test.v

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import log
22
import veb
33
import time
44
import net
5-
import x.json2
5+
import x.json2.decoder2
66
import net.http
77

88
const port = 31228
@@ -84,7 +84,7 @@ Priority: u=4\r
8484
assert response.contains('Content-Length: 706')
8585
assert response.contains('Content-Type: application/json')
8686
payload := response.all_after('\r\n\r\n')
87-
r := json2.decode[http.FileData](payload)!
87+
r := decoder2.decode[http.FileData](payload)!
8888
dump(r.filename)
8989
dump(r.content_type)
9090
assert r.filename == 'Seeker.svg'

vlib/veb/tests/veb_test.v

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import time
33
import x.json2 as json
4+
import x.json2.decoder2
45
import net
56
import net.http
67
import io
@@ -205,7 +206,7 @@ fn test_http_client_json_post() {
205206
}
206207
assert x.header.get(.content_type)! == 'application/json'
207208
assert x.body == json_for_ouser
208-
nuser := json.decode[User](x.body) or { User{} }
209+
nuser := decoder2.decode[User](x.body) or { User{} }
209210
assert '${ouser}' == '${nuser}'
210211

211212
x = http.post_json('http://${localserver}/json', json_for_ouser) or { panic(err) }
@@ -214,7 +215,7 @@ fn test_http_client_json_post() {
214215
}
215216
assert x.header.get(.content_type)! == 'application/json'
216217
assert x.body == json_for_ouser
217-
nuser2 := json.decode[User](x.body) or { User{} }
218+
nuser2 := decoder2.decode[User](x.body) or { User{} }
218219
assert '${ouser}' == '${nuser2}'
219220
}
220221

vlib/vweb/tests/vweb_test.v

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// vtest build: !windows
22
import io
33
import x.json2 as json
4+
import x.json2.decoder2
45
import time
56
import net
67
import net.http
@@ -150,7 +151,7 @@ fn test_http_client_json_post() {
150151
}
151152
assert x.header.get(.content_type)! == 'application/json'
152153
assert x.body == json_for_ouser
153-
nuser := json.decode[User](x.body) or { User{} }
154+
nuser := decoder2.decode[User](x.body) or { User{} }
154155
assert '${ouser}' == '${nuser}'
155156

156157
x = http.post_json('http://${localserver}/json', json_for_ouser) or { panic(err) }
@@ -159,7 +160,7 @@ fn test_http_client_json_post() {
159160
}
160161
assert x.header.get(.content_type)! == 'application/json'
161162
assert x.body == json_for_ouser
162-
nuser2 := json.decode[User](x.body) or { User{} }
163+
nuser2 := decoder2.decode[User](x.body) or { User{} }
163164
assert '${ouser}' == '${nuser2}'
164165
}
165166

0 commit comments

Comments
 (0)