2017-03-20 10 views
1

json에서 요소를 마스크하고 싶습니다. 아래 json의 descID 요소는 가려 져야합니다. 제발 제안 할 수 있겠 니?dataweave를 사용하여 복잡한 json 구조의 값을 마스크하는 방법은 무엇입니까?

{ 
    "status": "ok", 
    "statusCode": "19x9s011", 
    "statusDescription": "Service: XYZ IOP ; country: india ; Locale:en-US ; SourceId:KOP; ApiUid: 644e1dd7-2a7f-18fb-b8ed-ed78c3f899s2c2b; Description: The NMK profile call was successful.", 
    "details": { 
     "descID": "11840000000012698", 
     "Code": "XX", 
     "languageCode": "en", 
     "profile": { 
      "base": { 
       "username": "abc", 
       "firstName": "xc", 
       "middleName": "test", 
       "lastName": "123", 
       "shortName": "xc", 
       "displayName": "D", 
       "suffix": "T", 
       "prefix": "E" 
      } 
     } 
    } 
} 

답변

1

내가 데이터 마스킹 뭔가를 좋아 사용할 수 있습니다 : 당신은 그때처럼 뭔가를 사용할 수 있습니다, 전부 필드를 제거해야하는 경우이 https://blogs.mulesoft.com/dev/training-dev/encrypt-specific-xml-tags-with-the-power-of-dataweave/

에서 그대로 촬영

%dw 1.0 
%input payload application/json 
%output application/json 


%var keyToEncrypt = ['descID'] 

%function encrypt(val) "*****" 

%function needsEncrypt(key) (sizeOf (keyToEncrypt find key)) > 0 


%function maskSensitiveData(value) value mapObject ({ 
($$) : maskSensitiveData($) when $ is :object otherwise $ 
} unless needsEncrypt($$ as :string) otherwise { 
($$) : encrypt($) 
}) 

--- 

maskSensitiveData(payload) 

를 :

%dw 1.0 
%input payload application/json 
%output application/json 


%var keyToEncrypt = ['descID'] 

%function encrypt(val) "*****" 

%function needsEncrypt(key) (sizeOf (keyToEncrypt find key)) > 0 


%function maskSensitiveData(value) value mapObject ({ 
($$) : maskSensitiveData($) when $ is :object otherwise $ 
} unless needsEncrypt($$ as :string) otherwise {}) 

--- 

maskSensitiveData(payload) 
+0

안녕하세요. 답장을 보내 주셔서 감사합니다. 내 요구 사항은 자체가 없어야하는 출력 descID 요소에 있습니다. 그것이 상태 코드처럼 첫 번째 레벨에 직접 있다면 나는 paylaod - staus처럼 그것을 할 수 있습니다. 하지만 제거 할 요소가 여러 수준 아래에 있다면 정확히 어떻게 처리 할 수 ​​있습니까? – Sushma

+0

@Sushma 내 대답을 업데이트했습니다. –