Asal.StringExtentions 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Asal.StringExtentions --version 1.1.0
NuGet\Install-Package Asal.StringExtentions -Version 1.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Asal.StringExtentions" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Asal.StringExtentions --version 1.1.0
#r "nuget: Asal.StringExtentions, 1.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Asal.StringExtentions as a Cake Addin
#addin nuget:?package=Asal.StringExtentions&version=1.1.0

// Install Asal.StringExtentions as a Cake Tool
#tool nuget:?package=Asal.StringExtentions&version=1.1.0

**How to install Asal.StringExtentions ?

-You can easily install it from Manage Nuget package and write Asal so it will display for you as "Asal.StringExtentions" click download.

**How can I use it ?

-Once you downloaded the package, you can use it on the string itself.. e.g (yourStr."Choose the method that you want to use from the extentions"):-

(1)-> yourStr.ClearSpecialCharacters(optinal param) → This extention take an optional param if you want to replace a space after the char cleared, false by default.

(2)-> yourStr.ClearDigits(optinal param) → This extention take an optional param if you want to replace a space after the digits cleared, false by default.

(3)-> yourStr.Humanize() → Extention to humanize string (separate str by space).


(4)-> yourStr.IsValidEmail() → Extention to check the e-mail if it`s valid or not, return true or false.

(5)-> yourStr.ExtractEmails() → Extention to extract all valid emails in the giving string.


(6)-> yourJsonStrBody.ExtractJsonPropertyValue<T>(string jsonProperty)-> This extention extract a json property value that related to the giving jsonProperty parameter.

Examples:::

****lets say we have a json body like the following : jsonBody = "{"name":"John","age":30,"cars":["Ford", "BMW", "Fiat"]}"

and I want to extract the name of the json property, all you need to do is call the ExtractJsonPropertyValue extention and specify the method return type.

( var result = jsonBody.ExtractJsonPropertyValue<string>("name"); So in this point the result will be as "John". )

Lets say I want to get a property value inside object which is the age ? lets take another Josn body..

JsonBody = "{"data":[{"baseObject":{"name": "test", "age": 25 }},{"name":"test2"}]}"

answer:

( var result = jsonBody.ExtractJsonPropertyValue<int>("data[0].baseObject.age"); Now, the result will be 25

**what about the name ? var result = jsonBody.ExtractJsonPropertyValue<string>("data[0].baseObject.name"); Now, the result will be "test" )

**How can i extract the object itself ? JsonBody = "{"data":[{"baseObject":{"name": "test", "age": 25 }},{"name":"test2"}]}"

//data[0] represents the first index of the array

answer: ( var result = jsonBody.ExtractJsonPropertyValue<object>("data[0].baseObject"); so the result will be an object that contains the name with it`s value and same for the age. {"name": "test", "age": 25 } )

**How can i get the second object ? JsonBody = "{"data":[{"baseObject":[{"name": "test", "age": 25 }, {"name": "test2", "age": 27 }]},{"name":"test2"}]}"

//baseObject[0] → represents the first object inside baseObject array //baseObject[1] → represents the second object inside baseObject array

answer: ( var result = jsonBody.ExtractJsonPropertyValue<object>("data[0].baseObject[1]"); so the result will be an object that contains the name with it`s value and same for the age. {"name": "test2", "age": 27 }

**Lets say i need now the first object ? var result = jsonBody.ExtractJsonPropertyValue<object>("data[0].baseObject[0]"); so the result will be {"name": "test", "age": 25 }

*****First object name ? var result = jsonBody.ExtractJsonPropertyValue<object>("data[0].baseObject[0].name"); )


(7)-> yourJsonStrBody.TryExtractJsonPropertyValue<T>(string jsonProperty, out T result)-> This extention extract a json property value that related to the giving jsonProperty parameter, a the second parameter represent out result.. so you should specify the T type, no exceptions giving in the extention if it was an error it will return the default of T type in the out result and false as boolean for the method return type.

so after the call happened with success you can use the method value which is bool value Or can take the out result which is the actual data value.

Note: the extraction will be same as ExtractJsonPropertyValue<T>(string jsonProperty) extention but without exceptions.

Example: var input = "{"data":[{"baseObject":{"name": "test", "age": 25 }},{"name":"test2"}]}";

var res = input.TryExtractJsonPropertyValue<int>("data[0].baseObject.age", out var result);

result will be 25

//res value as bool and result have the actual data value depending on the T type


(8)-> yourJsonStrBody.ExtractJsonArrayPropertyValue<T>(string jsonProperty)-> This extention will extract an array values, the return type of it is IEnumerable<T> .

Example: var input = "{"name":"John","age":30,"cars":["Ford", "BMW", "Fiat"]}";

in this example let`s say that i want to get "cars" values which is an array.

answer: ( var res = input.ExtractJsonArrayPropertyValue<string>("cars"); the res value will be List<string> { "Ford", "BMW", "Fiat" } )

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.6.1 88 4/15/2024
1.6.0 83 4/15/2024
1.5.4 162 5/26/2023
1.5.0 102 5/24/2023
1.4.0 103 5/1/2023
1.3.0 140 4/16/2023
1.2.1 184 3/29/2023
1.1.0 178 3/29/2023
1.0.3 190 3/15/2023
1.0.2 189 3/15/2023
1.0.1 191 3/14/2023
1.0.0 176 3/14/2023

Build new extentions for the json values; which is allow to extract json property value and thats include the direct property extraction value or property inside object or even array values and more.