2
0

Omit empty _mpw_ext & unneeded escaping.

This commit is contained in:
Maarten Billemont 2018-07-09 01:12:28 -04:00
parent 5cdff6f155
commit 529f1feace
2 changed files with 5 additions and 3 deletions

View File

@ -46,7 +46,7 @@ time_t mpw_mktime(
tm.tm_year -= 1900; // tm_year 0 = rfc3339 year 1900 tm.tm_year -= 1900; // tm_year 0 = rfc3339 year 1900
tm.tm_mon -= 1; // tm_mon 0 = rfc3339 month 1 tm.tm_mon -= 1; // tm_mon 0 = rfc3339 month 1
// mktime interprets tm as local & writes TZ to tm_gmtoff; offset its result back to UTC. // mktime converts tm to local, setting tm_gmtoff; use it to offset the result back to UTC.
return mktime( &tm ) + tm.tm_gmtoff; return mktime( &tm ) + tm.tm_gmtoff;
} }

View File

@ -331,14 +331,16 @@ static bool mpw_marshal_write_json(
} }
json_object *json_site_mpw = json_object_new_object(); json_object *json_site_mpw = json_object_new_object();
json_object_object_add( json_site, "_ext_mpw", json_site_mpw );
if (site->url) if (site->url)
json_object_object_add( json_site_mpw, "url", json_object_new_string( site->url ) ); json_object_object_add( json_site_mpw, "url", json_object_new_string( site->url ) );
if (json_object_object_length( json_site_mpw ))
json_object_object_add( json_site, "_ext_mpw", json_site_mpw );
mpw_free_strings( &content, &loginContent, NULL ); mpw_free_strings( &content, &loginContent, NULL );
} }
mpw_string_pushf( out, "%s\n", json_object_to_json_string_ext( json_file, JSON_C_TO_STRING_PRETTY | JSON_C_TO_STRING_SPACED ) ); mpw_string_pushf( out, "%s\n", json_object_to_json_string_ext( json_file,
JSON_C_TO_STRING_PRETTY | JSON_C_TO_STRING_SPACED | JSON_C_TO_STRING_NOSLASHESCAPE ) );
mpw_free( &masterKey, MPMasterKeySize ); mpw_free( &masterKey, MPMasterKeySize );
json_object_put( json_file ); json_object_put( json_file );