I have some test data (json files) that I am using while testing some software. It is static data and I need the tests to run locally and on build machines that I don't have to much control of. In order to get uniform access to the test data (json files) I have put them into a RESX file and that is working nicely except that I had to change the extension of the file from .json to .txt.
If I left it as .json it was added to the resx file as a "Binary" instead of "Text File". This by itself wasn't the end of the road... I simply read out the bits and converted it back to a string but when I tried to deserialize the string (after the conversion from byte[]) I got an exception for unexpected char at position 0 line 0.
The only real downside to the "txt" extension is that I loose the color coding in the IDE for a JSON file.
Is there a way to force the RESX to treat the .json extension as a "Text File"?
The JSON format natively doesn't support binary data. The binary data has to be escaped so that it can be placed into a string element (i.e. zero or more Unicode chars in double quotes using backslash escapes) in JSON. An obvious method to escape binary data is to use Base64.
resx resource file format consists of XML entries that specify objects and strings inside XML tags. One advantage of a . resx file is that when opened with a text editor (such as Notepad) it can be written to, parsed, and manipulated.
resx file contains a standard header, which describes the format of the resource entries and specifies the versioning information for the XML that is used to parse the data. The resource file data follows the XML header. Each data item consists of a name/value pair that is contained in a data tag.
resx) files are a monolingual file format used in Microsoft . Net Applications. The . resx resource file format consists of XML entries, which specify objects and strings inside XML tags.
Maybe it's too late, but there is a very simple method to achieve what you want. Just select the desired file in the resources window, hit F4 or go to the Properties and select proper FileType there. It has two options: binary and text.
A colleague of mine just encountered a similar issue with a .cshtml
file. The actual content of the file didn't seem to matter when we renamed the file to have an extension that was known to work caused it to add as text.
Also, Axm's suggestion worked to fix it, but we initially missed it because you can't right-click on the resource and select properties.
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