mirror of
https://github.com/TheWhiteDog9487/WebAPI.git
synced 2026-10-08 00:51:15 +08:00
增加任意类型转换到Json静态函数
This commit is contained in:
1 parent
9de8b2c95c
commit
7d7810084e
1 file changed
+6
@@ -26,4 +26,10 @@ public record ResponseData(
|
|||||||
return JsonMapper.writeValueAsString(this);
|
return JsonMapper.writeValueAsString(this);
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
throw new RuntimeException(e); } }
|
throw new RuntimeException(e); } }
|
||||||
|
|
||||||
|
public static String AnyToJson(Object obj){
|
||||||
|
try {
|
||||||
|
return JsonMapper.writeValueAsString(obj);
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
throw new RuntimeException(e); } }
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user