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) { function readDirGeneric(dirpath: string, command: Function) {
return command(normalizeFilePath(dirpath)).then(files => { return command(normalizeFilePath(dirpath)).then(files => {
return files.map(file => ({ return files.map(file => ({
created: file.created && new Date(file.created) || null, ctime: file.ctime && new Date(file.ctime * 1000) || null,
modified: new Date(file.modified), mtime: new Date(file.mtime * 1000),
name: file.name, name: file.name,
path: file.path, path: file.path,
size: file.size, size: file.size,

View File

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

View File

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