Json configuration file

jabsaidijabsaidi Member ✭✭
edited February 25 in Xamarin.Forms

Hey guys, I'm trying to add to my project a config.json file. I am following the steps indicated in the documentation article about this. https://xamarinhelp.com/configuration-files-xamarin-forms/

The very last step is to load the configuration files with this function:

public static async Task<IConfiguration> Build(IFileStorage fileStorage)
{ 
    var platformFile = await fileStorage.ReadAsString("platform.json");

    var platform = JsonConvert.DeserializeObject<Platform>(platformFile);

    var configurationFile = await fileStorage.ReadAsString("config.json");

    var configuration = JsonConvert.DeserializeObject<Definition.Configuration>(configurationFile);

    configuration.Platform = platform;

    return configuration;
}

But I can't make it work, as this line:

            var configuration = JsonConvert.DeserializeObject<Definition.Configuration>(configurationFile);

Is giving me an error on the word "Definition" saying that it cannot find the type or namespace "Definition" within my project. I have tried all I could (which is not much as I'm pretty new to this) and can't seem to make it work.

Anybody knows what I might be missing? As I followed each step of the article.

Best Answers

  • jabsaidijabsaidi ✭✭
    Accepted Answer

    FIXED.

  • yelinzhyelinzh Xamurai
    Accepted Answer

    Congrats, and thanks very much for sharing the solution.

Answers

  • jabsaidijabsaidi Member ✭✭
    Accepted Answer

    FIXED.

  • TaylorDTaylorD USMember ✭✭✭

    Please post the solution / steps performed to fix the issue. This is helpful to users that may encounter this thread later on with a similar issue.

  • NMackayNMackay GBInsider, University mod

    @TaylorD said:
    Please post the solution / steps performed to fix the issue. This is helpful to users that may encounter this thread later on with a similar issue.

    +1

    FIXED helps no one.

  • yelinzhyelinzh Member, Xamarin Team Xamurai
    Accepted Answer

    Congrats, and thanks very much for sharing the solution.

Sign In or Register to comment.