
Convertir Json en CSV FileMaker
Guao esta función me llevo por lo menos un par de días en hacerla, la intención era crear un JSON con los datos necesarios y luego transformarlo en un CSV para poder establecer campo para si poder exportar el CSV y poder abrirlo en Excel, No hace falta plugin.
Nombre : JsonToCsv
Parámetros: json
Ejemplo: JsonToCsv(json)
¡Dona Conviértete en héroe!
/* Descripción: Esta función transforma un JSON a un CSV. NOTA: Formato de JSON que acepta es [ {id : xx}, {id : xy}, {id : xz}, ] el separador predeterminado es coma ( , ) Autor: www.Jteixcode.com */ Let ( [ _r = While ( [ _json = json ; _i = 0; _reg = ""; _cabecera = GetAsText ( Substitute ( JSONListKeys ( _json ; 0 ) ; "¶" ; "," ) )&"¶"; _countjson = ValueCount( JSONListKeys ( _json ; "" ) ); _lineanew = ""; _csv = "" ] ; _i < _countjson ; [ _reg = JSONGetElement ( _json ; "[" & _i & "]" ); _i = _i + 1; _lineanew = While ( [ _keys = JSONListKeys ( _reg ; "" ); _countkey = ValueCount( _keys ); _linea = ""; _lineanew = ""; _valor = ""; _key = "" ; _e = "" ] ; _e < _countkey ; [ _e = _e + 1 ; _key = GetValue ( _keys ; _e ); _valor = If ( IsEmpty ( JSONGetElement ( _reg ; _key )); "SD"; JSONGetElement ( _reg ; _key ) ); _linea = Case ( _e = 1 ; _valor&"," ; _e = _countkey ; _linea&_valor&"¶"; _linea&_valor&"," ); _lineanew = Case ( _e = _countkey and IsEmpty ( _lineanew ) ; _linea ; _e = _countkey and not IsEmpty ( _lineanew ) ; _lineanew &_linea ) ] ; _lineanew ); _csv = Case ( IsEmpty ( _csv ) ; _lineanew ; _csv & _lineanew ) ] ; _cabecera&_csv ) ] ; _r )
¡Dona Conviértete en héroe!
Mira Otras funciones que te pueden Interesar

Calcular cuantos años tiene una persona

alertas de bootstrap

funcion recursiva en FileMaker

Comprobar Código IBAN

Cómo Recorrer un String y Obtener un Valor en FileMaker

Remover Query Parameters de una URL

Cambiar Fecha de SQL a FileMaker

Sumar o Restar Porcentajes – Claris FileMaker

Quitar Caracteres Especial de un Texto – Claris FileMaker

Convertir un JSON En Lista – Claris FileMaker

Crear json a Partir de otro json – Claris FileMaker

Cambiar Formato de Numero de SQL a Formato FileMaker

Calcular el tiempo entre dos fechas en FileMaker

Fecha con 2 digitos – Claris FileMaker

Obtener lista de el último día de cada mes – Claris FileMaker
