Actual Json
{
"hits": {
"hits": [
{
"_source": {
"customer": {
"name": "Gnana",
"address": {
"AdrLine": "11 main lane",
"zipcode": "08598"
},
"contact": {
"firstcontact": "fff",
"secondcontact": "yyyy"
}
}
}
}
]
}
}
Joltspec
[
{
"operation": "shift",
"spec": {
"hits": {
"hits": {
"": {
"_source": {
"customer": {
"name": "customers[&3].&1.name",
"address": {
"AdrLine": "customers[&4].&2.&1.adrline",
"Country": "customers[&4].&2.&1.country"
},
"contact": {
"firstcontact": "customers[&4].&2.&1.contact1",
"secondcontact": "customers[&4].&2.&1.contact2"
}
}
}
}
}
}
}
},
{
"operation": "default",
"spec": {
"customers[]": {
"": {
"customer": null
}
}
}
}
]
I get the desired output with the following spec.
{
"customers": [
{
"customer": {
"name": "Gnana",
"address": {
"adrline": "11 main lane"
},
"contact": {
"contact1": "fff",
"contact2": "yyyy"
}
}
}
]
}
客户为空的情况2
{
"hits": {
"hits": [
{
"_source": {
"customer": null
}
}
]
}
}
I need output as
{
"customers": [
{
"customer": null
}
]
}
I am not getting customer:null in actual transformation
{
"customers": []
}
scenario 2 with address as null in customer object
{
"hits": {
"hits": [
{
"_source": {
"customer": {
"name": "Gnana",
"address": null,
"contact": {
"firstcontact": "fff",
"secondcontact": "yyyy"
}
}
}
}
]
}
}
Here address is null and I need output as
{
"customers": [
{
"customer": {
"name": "Gnana",
"address": null,
"contact": {
"contact1": "fff",
"contact2": "yyyy"
}
}
}
]
}
但是我没有得到“地址”:实际转换中为空
{
"customers": [
{
"customer": {
"name": "Gnana",
"contact": {
"contact1": "fff",
"contact2": "yyyy"
}
}
}
]
}
当我需要客户时,如何处理Json中的(Customer)对象为null:我的响应中还有另一个对象中的Object为null(客户对象中的地址),因为我需要{customer:{Address:null} }进行Jolt转换。