You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
varreader=new Utf8JsonReader(Encoding.UTF8.GetBytes(json));// Copy the reader struct by value to avoid advancing the `reader`varpeakCopy= reader;
Assert.True(peakCopy.Read());// Start reading the object
Assert.Equal(JsonTokenType.StartObject, peakCopy.TokenType);
Assert.True(peakCopy.Read());
Assert.Equal(JsonTokenType.PropertyName, peakCopy.TokenType);// Peak the property namevarpropertyName= peakCopy.GetString();if(propertyName=="$type"){// Assign the input ref to the peakreader=peakCopy;// Read the type value
Assert.True(reader.Read());
Assert.Equal(JsonTokenType.String, reader.TokenType);vartypeName= reader.GetString();// Read the remaining properties for the descendent type here...}elseif(propertyName!=null){// Read the remaining properties for the descendent type here...varelement= JsonElement.ParseValue(ref reader);// Get the $type propertyif(!element.TryGetProperty("$type",outvar typeName)){thrownew JsonException("Missing $type property.");}// Deserialize the `element` as the desired type}
The text was updated successfully, but these errors were encountered:
PoC:
The text was updated successfully, but these errors were encountered: