Cloud Stack Ninja

I am trying to deserializing a escaped string of json using Newtonsoft.

I have a simple unit test setup to isolate it shown below.

I am getting JsonReaderException of After parsing a value an unexpected character was encountered: F. Path 'YadaYadaBucket', line 1, position 22.

What am I doing wrong?

[Fact]
        public void DeserializeTest()
        {
            var json = "{\"YadaYadaBucket\": \"{\"Fn::GetArtifactAtt\":[\"BuildArtifact\",\"BucketName\"]}\", \"YadaYadaKey\": \"{\"Fn::GetArtifactAtt\":[\"BuildArtifact\",\"ObjectKey\"]}\"}";
            // throws Newtonsoft.Json.JsonReaderException : After parsing a value an unexpected character was encountered: F. Path 'YadaYadaBucket', line 1, position 22.
            var r = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);

        }```


Read more here: https://stackoverflow.com/questions/64397749/problems-deserializing-dictionarystring-string-with-json-net

Content Attribution

This content was originally published by Tim Bassett at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: