Exemplo n.º 1
0
        private static string Standardize(ElementNode node)
        {
            FhirJsonSerializationSettings serializationSettings = new FhirJsonSerializationSettings
            {
                Pretty = true,
            };

            return(node.ToJson(serializationSettings));
        }
        private static string Standardize(string jsonContent)
        {
            var resource = new FhirJsonParser().Parse <Resource>(jsonContent);
            FhirJsonSerializationSettings serializationSettings = new FhirJsonSerializationSettings
            {
                Pretty = true
            };

            return(resource.ToJson(serializationSettings));
        }
        public string AnonymizeJson(string json, AnonymizerSettings settings = null)
        {
            EnsureArg.IsNotNullOrEmpty(json, nameof(json));

            var      resource           = _parser.Parse <Resource>(json);
            Resource anonymizedResource = AnonymizeResource(resource, settings);

            FhirJsonSerializationSettings serializationSettings = new FhirJsonSerializationSettings
            {
                Pretty = settings != null && settings.IsPrettyOutput
            };

            return(anonymizedResource.ToJson(serializationSettings));
        }
        public string AnonymizeJson(string json, AnonymizerSettings settings = null)
        {
            EnsureArg.IsNotNullOrEmpty(json, nameof(json));

            var element           = ParseJsonToTypedElement(json);
            var anonymizedElement = AnonymizeElement(element);

            var serializationSettings = new FhirJsonSerializationSettings
            {
                Pretty = settings != null && settings.IsPrettyOutput
            };

            return(anonymizedElement.ToJson(serializationSettings));
        }
Exemplo n.º 5
0
        public string AnonymizeJson(string json, bool isPrettyOutput = false)
        {
            EnsureArg.IsNotNullOrEmpty(json, nameof(json));

            ElementNode root;

            try
            {
                root = ElementNode.FromElement(_parser.Parse(json).ToTypedElement());
            }
            catch (Exception innerException)
            {
                throw new Exception("Failed to parse json resource, please check the json content.", innerException);
            }

            FhirJsonSerializationSettings settings = new FhirJsonSerializationSettings
            {
                Pretty = isPrettyOutput
            };

            return(AnonymizeResourceNode(root).ToJson(settings));
        }
        public string AnonymizeJson(string json, AnonymizerSettings settings = null)
        {
            EnsureArg.IsNotNullOrEmpty(json, nameof(json));

            ElementNode root;
            Resource    resource;

            try
            {
                resource = _parser.Parse <Resource>(json);
                root     = ElementNode.FromElement(resource.ToTypedElement());
            }
            catch (Exception innerException)
            {
                throw new Exception("Failed to parse json resource, please check the json content.", innerException);
            }

            if (settings != null && settings.ValidateInput)
            {
                _validator.ValidateInput(resource);
            }
            var anonymizedNode = AnonymizeResourceNode(root);

            if (settings != null && settings.ValidateOutput)
            {
                anonymizedNode.RemoveNullChildren();
                _validator.ValidateOutput(anonymizedNode.ToPoco <Resource>());
            }

            FhirJsonSerializationSettings serializationSettings = new FhirJsonSerializationSettings
            {
                Pretty = settings != null && settings.IsPrettyOutput
            };

            return(anonymizedNode.ToJson(serializationSettings));
        }
 public string Serialize(
     ITypedElement element,
     FhirJsonSerializationSettings settings = null)
 {
     return(element.ToJson(settings));
 }