Class SDObjectDecoder

java.lang.Object
com.authlete.sd.SDObjectDecoder

public class SDObjectDecoder extends Object
A utility to decode selectively-disclosable elements in a map or a list recursively.
 // Original dataset
 //
 //   {
 //     "key-1": "value-1",
 //     "key-2": "value-2"
 //   }
 //
 Map<String, Object> originalMap = Map.of(
         "key-1", "value-1",
         "key-2", "value-2"
 );

 // Encoder
 SDObjectEncoder encoder = new SDObjectEncoder();

 // Encode
 Map<String, Object> encodedMap = encoder.encode(originalMap);

 // Disclosures yielded as a result of the encoding process.
 List<Disclosure> disclosures = encoder.getDisclosures();

 // Disclosures for claims to disclose.
 List<Disclosure> disclosed = disclosures.stream()
         .filter(d -> "key-1".equals(d.getClaimName()))
         .collect(Collectors.toList());

 // Decode the encoded map with the selected disclosures.
 SDObjectDecoder decoder = new SDObjectDecoder();
 Map<String, Object> decodedMap = decoder.decode(encodedMap, disclosed);

 // Decoded dataset
 //
 //   {
 //     "key-1": "value-1"
 //   }
 //
 
Since:
1.3