This repo contains the foundational libraries that make up the .NET Core development stack.
carlossanlop on 3.1
[release/3.1] Add RID for Aplin… (compare)
AA\((.+?)\)
to get the text inside the parenthesis after AA in AA(text)-AB(text2)-
AA()-AB(text2)
then the regex matches the whole string and i get )-AB(text2
extracted out. how can i get an empty result if there is no text in the parenthesis after AA?
AA\([^)]*\)
.+?
+
instead of *
?
@isobel-cullen - If they're not, you have a pretty dangerous race condition.
ValueTask
is mutable, more or less, but callers aren't supposed to muck with it (and are supposed to ignore it after successfully awaiting it, so don't have to deal with other modifications anyways).
hey, guys! can't figure it out how to create and obtain the value of object property in new writable JSON:
Person person = new() { Age = 22, Name = "Linda" };
JsonObject json = new()
{
["person"] = JsonValue.Create(person)
};
WriteLine((int)json["person"]["Age"]);
however, I get the error:
Unhandled exception. System.InvalidOperationException: The node must be of type 'JsonObject'.
at System.Text.Json.Node.JsonNode.AsObject() in System.Text.Json.dll:token 0x60005bb+0x20
at System.Text.Json.Node.JsonNode.get_Item(String propertyName) in System.Text.Json.dll:token 0x60005c5+0x0
at ConsoleApp.Program.TestJsonNodes() in E:\Projects\ConsoleApp\Program.cs:line 121
at ConsoleApp.Program.Main(String[] args) in E:\Projects\ConsoleApp\Program.cs:line 81
Function GetHash(sourceStr As String) As String
Dim b = ASCIIEncoding.ASCII.GetBytes(sourceStr)
Dim hash = New MD5CryptoServiceProvider().ComputeHash(b)
Dim sb As New StringBuilder(hash.Length)
For i = 0 To hash.Length - 1
sb.Append(hash(i).ToString("X2"))
Next
Return sb.ToString()
End Function
@Eugene was your intent to use an already-instantiated POCO?
If not, create the JsonObject directly
JsonObject jObject = new()
{
["person"] = new JsonObject()
{
["Age"] = 22,
["Name"] = "Linda"
}
};
If the intent was to use the POCO instance and not modify it as a JsonObject you can treat the POCO as a JsonValue:
Person person = new() { Age = 22, Name = "Linda" };
JsonObject jObject = new()
{
["person"] = JsonValue.Create(person)
};
If the intent was to use the POCO instance + treat it as a modifiable JsonObject, you'll need to serialize+deserialize:
Person person = new() { Age = 22, Name = "Linda" };
JsonObject jObject = new()
{
["person"] = JsonNode.Parse(JsonSerializer.Serialize(person)).AsObject()
};
Note that a new "CreateFromObject" helper could be added to JsonObject to make this easier for the latter sample:
Person person = new() { Age = 22, Name = "Linda" };
JsonObject jObject = new()
{
["person"] = JsonObject.CreateFromObject(person)
};