Fixed 'RCTJSONStringify() encountered the following error: Invalid type in JSON write (__NSTaggedDate)'

This commit is contained in:
Hagen Hübel 2017-04-27 13:07:19 +02:00
parent d21e0ea9f9
commit a5ee52f5c8
3 changed files with 5 additions and 5 deletions

View File

@ -161,8 +161,8 @@ function readFileGeneric(filepath: string, encodingOrOptions:?string, command: F
function readDirGeneric(dirpath: string, command: Function) {
return command(normalizeFilePath(dirpath)).then(files => {
return files.map(file => ({
created: file.created && new Date(file.created) || null,
modified: new Date(file.modified),
ctime: file.ctime && new Date(file.ctime * 1000) || null,
mtime: new Date(file.mtime * 1000),
name: file.name,
path: file.path,
size: file.size,

View File

@ -52,8 +52,8 @@ RCT_EXPORT_METHOD(readDir:(NSString *)dirPath
NSDictionary *attributes = [fileManager attributesOfItemAtPath:path error:nil];
return @{
@"created": [attributes objectForKey:NSFileCreationDate],
@"modified": [attributes objectForKey:NSFileModificationDate],
@"ctime": [self dateToTimeIntervalNumber:(NSDate *)[attributes objectForKey:NSFileCreationDate]],
@"mtime": [self dateToTimeIntervalNumber:(NSDate *)[attributes objectForKey:NSFileModificationDate]],
@"name": obj,
@"path": path,
@"size": [attributes objectForKey:NSFileSize],

View File

@ -259,7 +259,7 @@ public class RNFSManager extends ReactContextBaseJavaModule {
for (File childFile : files) {
WritableMap fileMap = Arguments.createMap();
fileMap.putString("modified", childFile.lastModified());
fileMap.putString("mtime", childFile.lastModified());
fileMap.putString("name", childFile.getName());
fileMap.putString("path", childFile.getAbsolutePath());
fileMap.putInt("size", (int)childFile.length());