Пример #1
0
 static JsonValue load(Stream stream, IJsonReader jsonReader, HjsonOptions options)
 {
     if (stream == null)
     {
         throw new ArgumentNullException("stream");
     }
     return(load(new StreamReader(stream, true), jsonReader, options));
 }
Пример #2
0
 static JsonValue load(TextReader textReader, IJsonReader jsonReader, HjsonOptions options)
 {
     if (textReader == null)
     {
         throw new ArgumentNullException("textReader");
     }
     return(new HjsonReader(textReader, jsonReader, options).Read());
 }
Пример #3
0
 /// <summary>Saves Hjson to a stream.</summary>
 public static void Save(JsonValue json, Stream stream, HjsonOptions options = null)
 {
     if (stream == null)
     {
         throw new ArgumentNullException("stream");
     }
     Save(json, new StreamWriter(stream), options);
 }
Пример #4
0
 /// <summary>Parses the specified Hjson/JSON string, optionally preserving whitespace and comments.</summary>
 public static JsonValue Parse(string hjsonString, HjsonOptions options)
 {
     if (hjsonString == null)
     {
         throw new ArgumentNullException("hjsonString");
     }
     return(Load(new StringReader(hjsonString), options));
 }
Пример #5
0
 /// <summary>Saves Hjson to a TextWriter.</summary>
 public static void Save(JsonValue json, TextWriter textWriter, HjsonOptions options = null)
 {
     if (textWriter == null)
     {
         throw new ArgumentNullException("textWriter");
     }
     new HjsonWriter(options).Save(json, textWriter, 0, false, "", true, true);
     textWriter.Flush();
 }
Пример #6
0
 /// <summary>Saves Hjson to a file.</summary>
 public static void Save(JsonValue json, string path, HjsonOptions options = null)
 {
     if (Path.GetExtension(path).ToLower() == ".json")
     {
         json.Save(path, Stringify.Formatted); return;
     }
     using (var s = File.CreateText(path))
         Save(json, s, options);
 }
Пример #7
0
 public HjsonReader(TextReader reader, IJsonReader jsonReader, HjsonOptions options)
     : base(reader, jsonReader)
 {
     if (options != null)
     {
         ReadWsc      = options.KeepWsc;
         dsfProviders = options.DsfProviders;
     }
 }
Пример #8
0
        /// <summary>Saves as Hjson to a string.</summary>
        public string ToString(HjsonOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }
            var sw = new StringWriter();

            HjsonValue.Save(this, sw, options);
            return(sw.ToString());
        }
Пример #9
0
 public HjsonWriter(HjsonOptions options)
 {
     if (options != null)
     {
         writeWsc       = options.KeepWsc;
         emitRootBraces = options.EmitRootBraces;
     }
     else
     {
         emitRootBraces = true;
     }
 }
Пример #10
0
 public HjsonWriter(HjsonOptions options)
 {
     if (options != null)
     {
         this.writeWsc       = options.KeepWsc;
         this.emitRootBraces = options.EmitRootBraces;
         this.dsfProviders   = options.DsfProviders;
     }
     else
     {
         this.emitRootBraces = true;
     }
 }
Пример #11
0
 static JsonValue load(string path, IJsonReader jsonReader, HjsonOptions options)
 {
     if (Path.GetExtension(path).ToLower() == ".json")
     {
         return(JsonValue.Load(path));
     }
     try
     {
         using (var s = File.OpenRead(path))
             return(load(s, jsonReader, options));
     }
     catch (Exception e) { throw new Exception(e.Message + " (in " + path + ")", e); }
 }
Пример #12
0
 /// <summary>Loads Hjson/JSON from a TextReader, optionally preserving whitespace and comments.</summary>
 public static JsonValue Load(TextReader textReader, HjsonOptions options, IJsonReader jsonReader = null)
 {
     return(load(textReader, jsonReader, options));
 }
Пример #13
0
 /// <summary>Loads Hjson/JSON from a stream, optionally preserving whitespace and comments.</summary>
 public static JsonValue Load(Stream stream, HjsonOptions options)
 {
     return(load(stream, null, options));
 }
Пример #14
0
 /// <summary>Loads Hjson/JSON from a file, optionally preserving whitespace and comments.</summary>
 public static JsonValue Load(string path, HjsonOptions options)
 {
     return(load(path, null, options));
 }
Пример #15
0
 /// <summary>Loads Hjson/JSON from a stream, optionally preserving whitespace and comments.</summary>
 public static JsonValue Load(Stream stream, HjsonOptions options) => load(stream, null, options);
Пример #16
0
 /// <summary>Loads Hjson/JSON from a file, optionally preserving whitespace and comments.</summary>
 public static JsonValue Load(string path, HjsonOptions options) => load(path, null, options);