defaultValues, Dispose fix

master
Harald Wolff 2017-12-07 20:17:29 +01:00
parent 580cf6a1d8
commit 197884e101
1 changed files with 9 additions and 3 deletions

12
JSON.cs
View File

@ -127,9 +127,11 @@ namespace sharp.json
} }
public void WriteTo(String filename,bool pretty) public void WriteTo(String filename,bool pretty)
{ {
FileStream fs = new FileStream(filename, FileMode.Create); using (FileStream fs = new FileStream(filename, FileMode.Create))
WriteTo(fs,pretty); {
fs.Close(); WriteTo(fs, pretty);
fs.Close();
}
} }
public static JSON ReadFrom(string filename) public static JSON ReadFrom(string filename)
@ -161,6 +163,10 @@ namespace sharp.json
} catch (FileNotFoundException e){ } catch (FileNotFoundException e){
return defaultValue; return defaultValue;
} }
if (source.Equals(""))
{
return defaultValue;
}
return parser.Parse(source); return parser.Parse(source);
} }