I would like to create a JSON object from a Resource File (.resx). I converted it to a ResouceSet as such:
ResourceSet resourceSet = MyResourceClass.ResourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, true);
I now have a set of objects in the form {Key:<key>, Value:<value>} but would instead like to convert it to JSON in the form or a hash map {Key:Value, ...}.
C# (pronounced "See Sharp") is a modern, object-oriented, and type-safe programming language. C# enables developers to build many types of secure and robust applications that run in . NET. C# has its roots in the C family of languages and will be immediately familiar to C, C++, Java, and JavaScript programmers.
No. The . NET Framework is a bunch of classes(libraries) abstracting some lower-level windows functionality. C and C++ are languages.
C++ is a object oriented programming language. But here . Net is a framework which supports multiple languages to build applications using . net class libraries which will be excueted via CLR .
NET is a free, cross-platform, open source developer platform for building many different types of applications. With . NET, you can use multiple languages, editors, and libraries to build for web, mobile, desktop, games, IoT, and more.
Since ResourceSet is an old collection class (HashTable) and uses DictionaryEntry, you need to convert the resourceSet to a Dictionary<string, string> and use Json.Net to serialize it:
resourceSet.Cast<DictionaryEntry>()
.ToDictionary(x => x.Key.ToString(),
x => x.Value.ToString());
var jsonString = JsonConvert.SerializeObject(resourceSet);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With