-
Notifications
You must be signed in to change notification settings - Fork 93
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
chore(client): json util supply method to parse json list #577
base: master
Are you sure you want to change the base?
Conversation
public static <T> List<T> fromJson2List(String json, Class<T> clazz) { | ||
try { | ||
return MAPPER.readValue(json, getCollectionType(List.class, clazz)); | ||
} catch (IOException e) { | ||
throw new SerializeException("Failed to deserialize json '%s'", e, json); | ||
} | ||
} | ||
|
||
private static JavaType getCollectionType(Class<?> collectionClass, | ||
Class<?>... elementClasses) { | ||
return MAPPER.getTypeFactory().constructParametricType(collectionClass, elementClasses); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shall we consider moving the JsonUtil to hugegraph-common
module?
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #577 +/- ##
============================================
+ Coverage 62.49% 62.54% +0.04%
- Complexity 1903 1925 +22
============================================
Files 262 267 +5
Lines 9541 9681 +140
Branches 886 888 +2
============================================
+ Hits 5963 6055 +92
- Misses 3190 3237 +47
- Partials 388 389 +1 ☔ View full report in Codecov by Sentry. |
@@ -60,4 +62,17 @@ public static <T> T convertValue(JsonNode node, Class<T> clazz) { | |||
e, node); | |||
} | |||
} | |||
|
|||
public static <T> List<T> fromJson2List(String json, Class<T> clazz) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to line 56?
Purpose of the PR
Main Changes
org.apache.hugegraph.util.JsonUtil
supply method to parse json list.Verifying these changes
org.apache.hugegraph.unit.JsonUtilTest
Does this PR potentially affect the following parts?
Documentation Status
Doc - TODO
Doc - Done
Doc - No Need