public static ISourceNode Read(JsonReader reader, string rootName = null, FhirJsonParsingSettings settings = null)
        {
            if (reader == null)
            {
                throw Error.ArgumentNull(nameof(reader));
            }

            var doc = SerializationUtil.JObjectFromReader(reader);

            return(new FhirJsonNode(doc, rootName, settings));
        }
示例#2
0
 public static IElementNavigator Create(JsonReader reader, string rootName = null)
 {
     try
     {
         JObject doc = null;
         doc = SerializationUtil.JObjectFromReader(reader);
         return(Create(doc, rootName));
     }
     catch (JsonException jec)
     {
         throw Error.Format("Cannot parse json: " + jec.Message);
     }
 }
示例#3
0
        public static IElementNavigator Create(JsonReader reader, string rootName = null)
        {
            try
            {
                JObject doc = null;
                doc = SerializationUtil.JObjectFromReader(reader);
                var type = doc.GetCoreTypeFromObject();

                if (type == null && rootName == null)
                {
                    throw Error.InvalidOperation("Root object has no type indication (resourceType) and therefore cannot be used to construct the navigator. Alternatively, specify a rootName using the parameter.");
                }

                return(new JsonDomFhirNavigator(rootName ?? doc.GetCoreTypeFromObject(), doc));
            }
            catch (JsonException jec)
            {
                throw Error.Format("Cannot parse json: " + jec.Message);
            }
        }