convert json string to C sharp values

Hi, i was wondering how to convert this Json string to C sharp values. so i can do something like this Values.StructValues.formattedPrice and it would return the price


“Key”: “productX36323”,
“Value”:
{
“formattedPrice”: “£0.00”,
“name”: “capainst pack”,
“productId”: “productX36323”,
“productType”: 1
}

//i've made these structs

public struct StructValues
	{
		public string formattedPrice {get;set;}
		public string name {get;set;}
		public string productId {get;set;}
		public string productType {get;set;}
	}

	public struct Values
	{
		public string Key {get;set;}
		public StructValues Value;
	}

You can take a look at these options:

Json.Net

DataContractJsonSerializer

JavaScriptSerializer

A json file is nothing more than a string. So you can isolate the part of the file you need and parse it into the type you need.

float GetFloatFromJson(string jsonFile, string key, bool frontToken) // key is the term we are after
    offset = frontToken ? 5 : 4; // This is to remove the ": "£ before the value, it could be 6
    // If there is no front token then pass on false

    int index = jsonFile.IndexOf(key)key.Length + offset; // At this point index should point to the first digit of the value
    
    string price = jsonFile.Substring(index);// Remove anything before the first digit
    int quotation = price.IndexOf("\""); // Look for first "
    price = price.Substring(0, quotation); // Isolate the digits
    float f = -1;
    try{
       f = float.Parse(price); // Parse to float
    }
    catch(Exception){
       // maybe here add some extra info to the user
       f = -1;
    }
    finally{
        return f;
    }
}

Note that I have not tried this so you could try and see if it goes.