using System.Collections.Generic;
public int Key { get; set; }
public int Value { get; set; }
public static void Main()
var xs = GetItems(new []{ 1, 2, 3});
var json = JsonConvert.SerializeObject(xs, Formatting.Indented);
static IEnumerable<Foo> GetItems(IEnumerable<int> vals) {
yield return new Foo { Key = v };