microsoft / slow-cheetah

Tooling for XML and JSON file transforms on build from Visual Studio and MSBuild
Other
323 stars 67 forks source link

JSON files: Data at the root level is invalid. Line 1, position 1. #108

Closed bryanparke closed 6 years ago

bryanparke commented 6 years ago

With any .json file that I attempt to preview the transform, I get the above error. Here is the sample input json:

{ "A" : { "A1" : "11" }, "B" : { "1B" : 12, "2B" : 22 }, "C" : { "C1" : 31, "C2" : 32 } }

No matter what, when I choose to preview the transform, the error is always "Data at the root level is invalid. Line 1, position 1." It is as if it doesn't work with JSON files and is expecting XML? Taking a wild guess.

bryanparke commented 6 years ago

I learned from some other issues that this error is happening when I do a Preview Transformation because the preview function appears to only work if the transform has an associated build / project configuration. There are 2 "preview transform" options when you right click a transform file, the first one fails (no error), the second one fails with the error mentioned in the original post. However, if I add a project config that matches the name of the transform, the preview works.

icnocop commented 6 years ago

The v2.5.48 release notes indicate that you have to manually uninstall the old version of SlowCheetah.

Would not uninstalling the old version cause the issue where you'd see two "Preview Transform" menu items?

davilimap commented 6 years ago

@bryanparke If I'm not mistaken, that issue is with XDT, but your file is JSON. As @icnocop mentioned, you probably have the older install version of SlowCheetah that only works with XML files. Can you verify that you have the latest version of the extension (3.0.61)?

TheMrAnderson commented 6 years ago

I'm having the same issue in an app that has never had the old version of Slow Cheetah. I added a brand new json file

davilimap commented 6 years ago

@TheMrAnderson what version of the SlowCheetah nuget package is installed in your project? The correct nuget package is Microsoft.VisualStudio.SlowCheetah which contains versions 3.0.56 and above, that support JSON transformations

TheMrAnderson commented 6 years ago

My apologies. I thought this issue was caused by Slow Cheetah, but it was caused by a previous extension I tried to use to transform JSON files. It wrote some config lines in my .csproj file that I had to manually remove. Once those were gone, Slow Cheetah did it's job.

davilimap commented 6 years ago

Closing for now, since it seems to be fixed. Please reopen if more assistance is needed.