liugddx commented on issue #3573:
URL:
https://github.com/apache/incubator-seatunnel/issues/3573#issuecomment-1331843861
> Hi, @liugddx Can you sync the result of this discuss here? And sync to the
email list is better.
After discussion,There are now two solutions
1. Provide flexible json-path placeholder configuration
`json_field [Config]`
This parameter helps you configure the schema,so this parameter must be used
with schema.
If your data looks something like this:
```
{
"store": {
"book": [
{
"category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{
"category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
},
"expensive": 10
}
```
You can get the contents of 'book' by configuring the task as follows:
```
source {
Http {
url = "http://mockserver:1080/jsonpath/mock"
method = "GET"
format = "json"
json_field = {
category = "$.store.book[*].category"
author = "$.store.book[*].author"
title = "$.store.book[*].title"
price = "$.store.book[*].price"
}
schema = {
fields {
category = string
author = string
title = string
price = string
}
}
}
}
```
2. Provides the ability to get partial json.
`content_json [String]`
This parameter can get some json data.If you only need the data in the
'book' section, configure content_field = "$.store.book.*".
If your return data looks something like this.
```
{
"store": {
"book": [
{
"category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{
"category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
},
"expensive": 10
}
```
You can configure content_field = "$.store.book.*" and the result returned
looks like this:
```
[
{
"category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{
"category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
}
]
```
Then you can get the desired result with a simpler schema,like
```
Http {
url = "http://mockserver:1080/contentjson/mock"
method = "GET"
format = "json"
content_field = "$.store.book.*"
schema = {
fields {
category = string
author = string
title = string
price = string
}
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]