This is a duplicate thread. The JSON data is not a table. The JSON data is a single object that contains two, maybe three, types; RecordLocator and Pnramount. Pnramount contains a collection of an unknown type; AlternateCurrencyCode.
Like your previous thread I recommend deserializing the JSON stream into a standard C# type. Working with a C# type is an easier type safe way to manipulate data than messing around with a JObject and string indexes. You'll find a basic code sample, similar to your other thread, below. The code sample uses a type, Record, to store the RecordLocator and AlternateCurrencyCode arrays as a delimited string. Feel free to modify the code to suite your needs.
public class Rootobject
{
public Recordlocator[] RecordLocator { get; set; }
public Pnramount PNRAmount { get; set; }
}
public class Pnramount
{
public string BalanceDue { get; set; }
public string AuthorizedBalanceDue { get; set; }
public string SegmentCount { get; set; }
public string PassiveSegmentCount { get; set; }
public string TotalCost { get; set; }
public string PointsBalanceDue { get; set; }
public string TotalPointCost { get; set; }
public string[] AlternateCurrencyCode { get; set; }
public string AlternateCurrencyBalanceDue { get; set; }
}
public class Recordlocator
{
public string PNR { get; set; }
}
public class Record
{
public string RecordLocator { get; set; }
public string BalanceDue { get; set; }
public string AuthorizedBalanceDue { get; set; }
public string SegmentCount { get; set; }
public string PassiveSegmentCount { get; set; }
public string TotalCost { get; set; }
public string PointsBalanceDue { get; set; }
public string TotalPointCost { get; set; }
public string AlternateCurrencyCode { get; set; }
public string AlternateCurrencyBalanceDue { get; set; }
}
public class Program
{
static void Main(string[] args)
{
string json = File.ReadAllText(@"C:/temp/json.txt");
Rootobject root = JsonConvert.DeserializeObject<Rootobject>(json);
Record r = new Record()
{
RecordLocator = string.Join(":", root.RecordLocator.Select(m => m.PNR)),
AlternateCurrencyBalanceDue = root.PNRAmount.AlternateCurrencyBalanceDue,
AlternateCurrencyCode = string.Join(", ", root.PNRAmount.AlternateCurrencyCode),
AuthorizedBalanceDue = root.PNRAmount.AuthorizedBalanceDue,
BalanceDue = root.PNRAmount.BalanceDue,
PassiveSegmentCount = root.PNRAmount.PassiveSegmentCount,
PointsBalanceDue = root.PNRAmount.PointsBalanceDue,
SegmentCount = root.PNRAmount.SegmentCount,
TotalCost = root.PNRAmount.TotalCost,
TotalPointCost = root.PNRAmount.TotalPointCost
};
foreach (var prop in r.GetType().GetProperties())
{
Console.WriteLine("{0} = {1}", prop.Name, prop.GetValue(r, null));
}
}
}