Add json marshalling to AddFlat/flattenStruct