def json_to_form(form_dict, sep=u'_', pre=u'', _ls=u'-'):
  """Convert a json dictionary to match the flat form fieldnames."""
  flat = []
  for key, val in form_dict.iteritems():
    key_name = pre + key if pre else key
    if isinstance(val, dict):
      leaf = json_to_form(val, sep=sep, pre=key_name + sep)
      flat += leaf
    elif isinstance(val, list) and (len(val) and isinstance(val[0], dict)):
      for i, row in enumerate(val):
        row_key = _ls.join([key_name, str(i)])
        leaf = json_to_form(row, sep=sep, pre=row_key + _ls)
        flat += leaf
    else:
      node = (key_name, val)
      if key_name != u'id' and val is not None:
        flat.append(node)
  return flat