-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Feature][Connector-V2][HTTP] Use json-path parsing #3510
Conversation
3869359
to
97c10c4
Compare
docs/en/connector-v2/source/Http.md
Outdated
|
||
### new version | ||
|
||
- Increase jsonpath parsing. |
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.
Add PR link.
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.
Please refer to the format of other changed logs. [Feature/Bugfix/Improve][XXX]
docs/en/connector-v2/source/Http.md
Outdated
@@ -124,6 +125,18 @@ connector will generate data as the following: | |||
|
|||
the schema fields of upstream data | |||
|
|||
### json_field [Config] | |||
|
|||
The Wildcards for jsonpath like |
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.
Add example json, and how to use json_field
with example json, like parse data in list. And if we have json_field
, do we need config schema or not? The answer of these question should be found in document.
By the way, this is a good feature. |
We have an issue discuss about this #3573. Can we wait for the discussion to finish before processing this pr? |
} | ||
} | ||
} | ||
``` |
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.
Please add real response json example in here.
# Conflicts: # seatunnel-connectors-v2/connector-http/connector-http-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/http/config/HttpConfig.java # seatunnel-connectors-v2/connector-http/connector-http-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/http/source/HttpSource.java
Hi, we have communicated about this issue. If you have other good suggestions, you can also put forward them. @Hisoka-X @EricJoy2048 @TaoZex |
|
List<?> result0 = results.get(0); | ||
List<?> result = results.get(i); | ||
if (result0.size() != result.size()) { | ||
throw new SeaTunnelException( |
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.
Use HttpConnectorException
private void initJsonPath(JsonField jsonField) { | ||
jsonPaths = new JsonPath[jsonField.getFields().size()]; | ||
final int[] index = {0}; | ||
jsonField.getFields().forEach((key, value) -> { |
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.
Use entrySet
is better, final int[] index = {0};
make the code not clear
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.
This is a very good feature. Thanks for you contribution.
| name | type | required | default value | | ||
| --------------------------- | ------ | -------- | ------------- | | ||
| url | String | Yes | - | | ||
| schema | Config | No | - | | ||
| schema.fields | Config | No | - | | ||
| json_field | Config | No | - | |
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.
Please add content_json
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.
Please add
content_json
Thanks for your code review.
add content_json
List<List<String>> datas = new ArrayList<>(); | ||
for (int i = 0; i < results.size(); i++) { | ||
List<String> result = results.get(i); | ||
if (i == 0) { | ||
for (Object o : result) { | ||
String val = o == null ? null : o.toString(); |
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.
The code on line 170 is probably not needed because result is of type List<String>.
Object o = result.get(j); | ||
String val = o == null ? null : o.toString(); |
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.
Same as above.
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.
Sometimes there is null data, which needs to be converted to a null string.It is necessary to do so
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.
+1
close #3500
Purpose of this pull request
Check list
New License Guide