Yes, you can use system.fieldPairs:
type T = object
a, b: int
var ob: T
for a, b in fieldPairs(ob):
echo a, " ", b
Note that the for loop isn't actually compiled to a loop. It'll be unrolled once for each object field, and you can then use when or overloading to choose a different implementation for a field name or type. See the system.nim code for an example how that can be done.