alibaba / alibaba/fastjson2

[FEATURE] 不同类集合间的复制实现

Open
#2,218 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
4.4k
Forks
613
Avg merge
1d 22h
Merged PRs (30d)
6

Description

### 请描述您的需求或者改进建议
*对您想要需求或建议的清晰简洁的描述。*
现我想用类似JSONArray.copyOf()来复制转换类A集合至另一个类B集合,如果支持改转化将会比较好用,以下是我期望的效果:

`
List entityToVOBatch(List all) {
// return all.stream().collect(ArrayList::new, (r, e) -> entityToVO(e), ArrayList::addAll);
return JSONArray.copyOf(all).toJavaList(OutstandingAchievementVO.class);
}
`
但是该实现会报错
class com.itime.debtdefuse.home.business.model.po.OutstandingAchievement cannot be converted to class com.itime.debtdefuse.home.business.model.vo.OutstandingAchievementVO

不知可否实现该功能

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the example with JSONArray.copyOf(all).toJavaList(OutstandingAchievementVO.class) and inspect the behavior of those APIs for source and target classes. Define the supported cross-class collection conversion and verify that the reported OutstandingAchievement to OutstandingAchievementVO case completes without the conversion error.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.