private static DynValue ParseJsonArray(Lexer L, Script script, bool emptyArray) { Table t = new Table(script); L.Next(); while (L.Current.Type != TokenType.Brk_Close_Square) { DynValue v = ParseJsonValue(L, script, emptyArray); t.Append(v); L.Next(); if (L.Current.Type == TokenType.Comma) { L.Next(); } } return(emptyArray && t.Length == 0 ? JsonEmptyArray.Create() : DynValue.NewTable(t)); }
/// <summary> /// Converts a generic object to JSON /// </summary> public static string ObjectToJson(object obj) { DynValue v = ObjectValueConverter.SerializeObjectToDynValue(null, obj, JsonNull.Create(), JsonEmptyArray.Create()); StringBuilder sb = new StringBuilder(); ValueToJson(sb, v); return(sb.ToString()); }