Skip to content

Commit

Permalink
skip @typ key for feature DuplicateKeyValueAsArray, for issue #3284
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Feb 9, 2025
1 parent 10e4381 commit 177f40d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
3 changes: 1 addition & 2 deletions core/src/main/java/com/alibaba/fastjson2/JSONReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -2244,8 +2244,7 @@ public void read(Map object, long features) {
continue;
}

if (i == 0
&& (contextFeatures & Feature.SupportAutoType.mask) != 0
if ((contextFeatures & Feature.SupportAutoType.mask) != 0
&& name.equals("@type")
&& object.getClass().getName().equals(value)
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.alibaba.fastjson2.issues_3200;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONReader;
import org.junit.jupiter.api.Test;

import java.util.HashMap;

import static org.junit.jupiter.api.Assertions.assertFalse;

public class Issue3284 {
@Test
public void test() {
String str = "{\"endDataTime\":\"2024\",\"@type\":\"java.util.HashMap\",\"startDataTime\":\"2023\"}";
HashMap hashMap = JSON.parseObject(str, HashMap.class, JSONReader.Feature.SupportAutoType);
assertFalse(hashMap.containsKey("@type"));
}
}

0 comments on commit 177f40d

Please sign in to comment.