Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@Body 静态内部类集合Collection字段无法正确序列化为数组 #220

Open
HK-hub opened this issue Jan 22, 2025 · 1 comment
Open

Comments

@HK-hub
Copy link

HK-hub commented Jan 22, 2025

问题描述

使用@Body 修饰的静态内部类参数的集合成员变量无法正确序列化为[....]形式,而被序列化为了e1,e2,e3,.....

请求日志:

	POST http://iip.yndsft.com/di-api/dacoo-api/openApi/exRedisManage/recentVal/batch?appKey=241230163120016500001&appSecret=cc2e452e911843b4bd3dac86d58b7e63 HTTP
	Headers: 
		User-Agent: forest/1.5.36
	Body: attrId=12174089,12174091,12174093,12174095,12174097,12174099,12174101,12174103

API接口方响应日志:

{
	"code":"1003",
	"data":null,
	"message":"com.alibaba.fastjson.JSONException: syntax error, expect {, actual error, pos 0, fastjson-version 1.2.47",
	"possibleReason":null,
	"suggestMeasure":null,
	"traceId":null
}

并且版本已经更新到了最新版1.5.36

Api类

@BaseRequest(baseURL = "http://iip.yndsft.com", interceptor = TagValueAccessInterceptor.class)
public interface TagDataAccessService {

    /**
     * 根据点位id批量获取点位最新值
     * 数据在落盘的同时会将最近值缓存至缓存库中,通过该接口获取最新值时效率最高,默认最多请求100个点。
     * @param tagAttributes
     * @return
     * @param <T>
     */
    @Post("/di-api/dacoo-api/openApi/exRedisManage/recentVal/batch")
    public <T> ApiResult<Map<String, TagValue<T>>> batchTagValueLatest(@Body TagValueAccessRequest.TagAttributes tagAttributes);

}

请求参数类

@Data
public class TagValueAccessRequest {
    @Getter
    @Setter
    public static class TagAttributes {

        /**
         * 点位id,未填点位全局标识时必填此项
         */
        private Collection<Integer> attrId;
    }
}

Forest依赖

        <dependency>
            <groupId>com.dtflys.forest</groupId>
            <artifactId>forest-spring-boot-starter</artifactId>
            <version>1.5.36</version>
        </dependency>
@HK-hub
Copy link
Author

HK-hub commented Jan 22, 2025

破案了, @Body默认使用的序列化方式是序列化成为Form格式吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant