@ -9,35 +9,37 @@ int32_t main(int32_t argc,char **argv)
if ( argc > 2 & & ( argjson = cJSON_Parse ( argv [ 2 ] ) ) ! = 0 )
if ( argc > 2 & & ( argjson = cJSON_Parse ( argv [ 2 ] ) ) ! = 0 )
{
{
fname = argv [ 1 ] ;
fname = argv [ 1 ] ;
printf ( " fname.%s \n " , argv [ 1 ] ) ;
if ( ( filestr = OS_filestr ( & filesize , fname ) ) ! = 0 )
if ( ( filestr = OS_filestr ( & filesize , fname ) ) ! = 0 )
{
{
if ( ( filejson = cJSON_Parse ( filestr ) ) ! = 0 )
if ( ( filejson = cJSON_Parse ( filestr ) ) ! = 0 )
{
{
if ( ( array = jarray ( & n , argjson , " fields " ) ) = = 0 )
if ( ( array = jarray ( & n , argjson , " fields " ) ) ! = 0 )
obj = jobj ( argjson , " field " ) , n = 1 ;
else obj = jitem ( array , 0 ) ;
for ( i = 0 ; i < n ; i + + )
{
{
if ( ( field = jfieldname ( obj ) ) ! = 0 )
for ( i = 0 ; i < n ; i + + )
{
{
if ( ( fobj = jobj ( filejson , field ) ) ! = 0 )
obj = jitem ( array , i ) ;
if ( ( field = jfieldname ( obj ) ) ! = 0 & & ( obj = obj - > child ) ! = 0 )
{
{
fstr = jprint ( fobj , 0 ) ;
if ( ( fobj = jobj ( filejson , field ) ) ! = 0 )
str = jprint ( obj , 0 ) ;
{
if ( strcmp ( fstr , str ) ! = 0 )
fstr = jprint ( fobj , 0 ) ;
printf ( " field.(%s) in (%s) mismatch (%s) != (%s) \n " , field , fname , fstr , str ) ;
str = jprint ( obj , 0 ) ;
free ( str ) ;
if ( strcmp ( fstr , str ) ! = 0 )
free ( fstr ) ;
{
} else printf ( " cant find field.(%s) in (%s) \n " , field , fname ) ;
printf ( " { \" error \" : \" field.(%s) in (%s) i.%d of n.%d mismatch (%s) != (%s) \" } \n " , field , fname , i , n , fstr , str ) ;
fprintf ( stderr , " { \" error \" : \" field.(%s) in (%s) i.%d of n.%d mismatch (%s) != (%s) \" } \n " , field , fname , i , n , fstr , str ) ;
}
else printf ( " { \" result \" : \" MATCHED.[%s] (%s) . ( % s ) \ " } \n " , fname , field , fstr ) ;
free ( str ) ;
free ( fstr ) ;
} else fprintf ( stderr , " cant find field.(%s) in (%s) \n " , field , fname ) ;
} else fprintf ( stderr , " no fieldname array[%d] \n " , i ) ;
}
}
if ( i < n - 1 )
} else fprintf ( stderr , " no fields array \n " ) ;
obj = jitem ( array , i + 1 ) ;
}
free_json ( filejson ) ;
free_json ( filejson ) ;
}
} else fprintf ( stderr , " cant parse.(%s) \n " , filestr ) ;
free ( filestr ) ;
free ( filestr ) ;
}
} else fprintf ( stderr , " cant load (%s) \n " , fname ) ;
} else printf ( " argc.%d fname.(%s) error \n " , argc , argv [ 1 ] ) ;
} else f printf( stderr , " argc.%d fname.(%s) error \n " , argc , argv [ 1 ] ) ;
}
}