File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed
main/java/com/alibaba/fastjson2
test/java/com/alibaba/fastjson2 Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -4733,7 +4733,12 @@ protected final String readStringNotMatch() {
4733
4733
List array = readArray ();
4734
4734
if (array .size () == 1 ) {
4735
4735
Object item = array .get (0 );
4736
- return item == null ? null : item .toString ();
4736
+ if (item == null ) {
4737
+ return null ;
4738
+ }
4739
+ if (item instanceof String ) {
4740
+ return item .toString ();
4741
+ }
4737
4742
}
4738
4743
return toString (array );
4739
4744
case '{' :
Original file line number Diff line number Diff line change
1
+ package com .alibaba .fastjson2 .issues_3400 ;
2
+
3
+ import com .alibaba .fastjson2 .JSON ;
4
+ import lombok .Data ;
5
+ import org .junit .jupiter .api .Test ;
6
+
7
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
8
+
9
+ public class Issue3438 {
10
+ @ Test
11
+ public void test () {
12
+ String aaa = "{\" file\" :[{\" url\" :\" http\" }]}" ;
13
+ Bbb bbb = JSON .parseObject (aaa , Bbb .class );
14
+ assertEquals ("[{\" url\" :\" http\" }]" , bbb .file );
15
+ }
16
+
17
+ @ Data
18
+ public static class Bbb {
19
+ String file ;
20
+ }
21
+ }
Original file line number Diff line number Diff line change @@ -163,13 +163,13 @@ void lexerTest(JSONReader lexer) {
163
163
assertEquals (Fnv .hashCode64 ("v12" ), lexer .readFieldNameHashCode ());
164
164
assertEquals (Fnv .hashCode64LCase ("v12" ), lexer .getNameHashCodeLCase ());
165
165
assertEquals ("v12" , lexer .getFieldName ());
166
- assertEquals ("1234" , lexer
166
+ assertEquals ("[ 1234] " , lexer
167
167
.readString ());
168
168
169
169
assertEquals (Fnv .hashCode64 ("v13" ), lexer .readFieldNameHashCode ());
170
170
assertEquals (Fnv .hashCode64LCase ("v13" ), lexer .getNameHashCodeLCase ());
171
171
assertEquals ("v13" , lexer .getFieldName ());
172
- assertEquals ("12.34" , lexer .readString ());
172
+ assertEquals ("[ 12.34] " , lexer .readString ());
173
173
174
174
assertEquals (Fnv .hashCode64 ("v14" ), lexer .readFieldNameHashCode ());
175
175
assertEquals (Fnv .hashCode64LCase ("v14" ), lexer .getNameHashCodeLCase ());
You can’t perform that action at this time.
0 commit comments