Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
9b36a4c
Added new methods in preparation for Jayrock replacement.
claudiamurialdo Oct 25, 2023
af10678
Remove invalid EventHandler variable instance. It must be associated …
claudiamurialdo Oct 25, 2023
c888eb5
Add a configuration setting, USE_JAYROCK, to replace Jayrock with Sys…
claudiamurialdo Oct 25, 2023
7d22909
Add new tests for deserialization using System.Text.Json.
claudiamurialdo Oct 31, 2023
f0612a1
Remove jayrock dependency from .NET (Core) classes and use System.Tex…
claudiamurialdo Oct 31, 2023
e1c4dd8
Keep the same encoding algorithm for the JSON returned to the client-…
claudiamurialdo Oct 31, 2023
2084643
Fix build error.
claudiamurialdo Oct 31, 2023
89f1c08
Replace the base class 'DictionaryBase' of 'JObject' with 'OrderedDic…
claudiamurialdo Nov 1, 2023
0b97173
Fix: The JSON array contains a trailing comma at the end which is not…
claudiamurialdo Nov 6, 2023
9f26e87
Change the WriteJSON method to serialize datetimes in the 'dd/MM/yyyy…
claudiamurialdo Nov 7, 2023
d0a080e
Avoid printing duplicate messages when deserializing an invalid JSON
claudiamurialdo Nov 8, 2023
dce7cc4
Merge branch 'master' into jayrock-to-system-text
claudiamurialdo Nov 8, 2023
09907b5
Register serialization converter for Geospatial data type.
claudiamurialdo Nov 9, 2023
61ec693
Enhance compatibility for TextJsonSerializer.WriteJSON<T> with JayRoc…
claudiamurialdo Nov 10, 2023
28d23e1
Boolean values must be serialized in lowercase to conform with JSON v…
claudiamurialdo Nov 15, 2023
286bb27
Merge branch 'master' into jayrock-to-system-text
claudiamurialdo Dec 14, 2023
23bab28
Fix merge errors with master.
claudiamurialdo Dec 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions dotnet/src/dotnetcore/GxClasses.Web/GxClasses.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,5 @@
<Folder Include="Notifications\WebSocket\" />
<Folder Include="View\UserControls\" />
</ItemGroup>
<ItemGroup>
<Reference Include="Jayrock-JSON" Condition="'$(TargetFramework)'=='net8.0'">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\libs\net8.0\Jayrock.dll</HintPath>
</Reference>
<Reference Include="Jayrock-JSON" Condition="'$(TargetFramework)'=='net6.0'">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\libs\Jayrock.dll</HintPath>
</Reference>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#if NETCORE
using GeneXus.Application;
#else
using Jayrock.Json;
#endif
using System;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -11,7 +16,6 @@
using GeneXus.Procedure;
using GeneXus.Services;
using GeneXus.Utils;
using Jayrock.Json;

namespace GeneXus.Http.WebSocket
{
Expand Down
360 changes: 360 additions & 0 deletions dotnet/src/dotnetcore/GxClasses/Domain/JArray.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,360 @@
#region License, Terms and Conditions
//
// Jayrock - A JSON-RPC implementation for the Microsoft .NET Framework
// Written by Atif Aziz (atif.aziz@skybow.com)
// Copyright (c) Atif Aziz. All rights reserved.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License as published by the Free
// Software Foundation; either version 2.1 of the License, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
// details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this library; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#endregion

namespace GeneXus.Application
{
#region Imports

using System;
using System.Collections;
using System.Globalization;
using System.Text;
using GeneXus.Utils;

#endregion

/// <summary>
/// An ordered sequence of values. This class also provides a number of
/// methods that can be found on a JavaScript Array for sake of parity.
/// </summary>
/// <remarks>
/// <para>
/// Public Domain 2002 JSON.org, ported to C# by Are Bjolseth (teleplan.no)
/// and re-adapted by Atif Aziz (www.raboof.com)</para>
/// </remarks>

[ Serializable ]
internal class JArray : CollectionBase, IJayrockCompatible
{
public JArray() {}

public JArray(IEnumerable collection)
{
foreach (object item in collection)
List.Add(item);
}

public virtual object this[int index]
{
get { return InnerList[index]; }
set { List[index] = value; }
}

public int Length
{
get { return Count; }
}

public JArray Put(object value)
{
Add(value);
return this;
}

public virtual void Add(object value)
{
List.Add(value);
}
public virtual void Add(int index, object value)
{
InnerList.Insert(index, value);
}

public virtual void Remove(object value)
{
List.Remove(value);
}

public virtual bool Contains(object value)
{
return List.Contains(value);
}

public virtual int IndexOf(object value)
{
return List.IndexOf(value);
}

public virtual bool HasValueAt(int index)
{
return this[index] != null;
}

public virtual object GetValue(int index)
{
return GetValue(index, null);
}

public virtual object GetValue(int index, object defaultValue)
{
object value = this[index];
return value != null ? value : defaultValue;
}

public virtual bool GetBoolean(int index)
{
return GetBoolean(index, false);
}

public virtual bool GetBoolean(int index, bool defaultValue)
{
object value = GetValue(index);
if (value == null) return defaultValue;
return Convert.ToBoolean(value, CultureInfo.InvariantCulture);
}

public virtual double GetDouble(int index)
{
return GetDouble(index, float.NaN);
}

public virtual double GetDouble(int index, float defaultValue)
{
object value = GetValue(index);
if (value == null) return defaultValue;
return Convert.ToDouble(value, CultureInfo.InvariantCulture);
}

public virtual int GetInt32(int index)
{
return GetInt32(index, 0);
}

public virtual int GetInt32(int index, int defaultValue)
{
object value = GetValue(index);
if (value == null) return defaultValue;
return Convert.ToInt32(value, CultureInfo.InvariantCulture);
}

public virtual string GetString(int index)
{
return GetString(index, string.Empty);
}

public virtual string GetString(int index, string defaultValue)
{
object value = GetValue(index);
if (value == null) return defaultValue;
return value.ToString();
}

public virtual JArray GetArray(int index)
{
return (JArray) GetValue(index);
}

public virtual JObject GetObject(int index)
{
return (JObject) GetValue(index);
}

protected override void OnValidate(object value)
{
//
// Null values are allowed in a JSON array so don't delegate
// to the base class (CollectionBase) implementation since that
// disallows null entries by default.
//
}

/// <summary>
/// Make an JSON external form string of this JsonArray. For
/// compactness, no unnecessary whitespace is added.
/// </summary>
/// <remarks>
/// This method assumes that the data structure is acyclical.
/// </remarks>

public override string ToString()
{
return TextJsonSerializer.SerializeToJayrockCompatibleJson(this);
}


/// <summary>
/// Copies the elements to a new object array.
/// </summary>

public virtual object[] ToArray()
{
return (object[]) ToArray(typeof(object));
}

/// <summary>
/// Copies the elements to a new array of the specified type.
/// </summary>

public virtual Array ToArray(Type elementType)
{
return InnerList.ToArray(elementType);
}

public virtual void Reverse()
{
InnerList.Reverse();
}

//
// Methods that imitate the JavaScript array methods.
//

/// <summary>
/// Appends new elements to an array.
/// </summary>
/// <returns>
/// The new length of the array.
/// </returns>
/// <remarks>
/// This method appends elements in the order in which they appear. If
/// one of the arguments is an array, it is added as a single element.
/// Use the <see cref="Concat"/> method to join the elements from two or
/// more arrays.
/// </remarks>

public int Push(object value)
{
Add(value);
return Count;
}

/// <summary>
/// Appends new elements to an array.
/// </summary>
/// <returns>
/// The new length of the array.
/// </returns>
/// <remarks>
/// This method appends elements in the order in which they appear. If
/// one of the arguments is an array, it is added as a single element.
/// Use the <see cref="Concat"/> method to join the elements from two or
/// more arrays.
/// </remarks>

public int Push(params object[] values)
{
if (values != null)
{
foreach (object value in values)
Push(value);
}

return Count;
}

/// <summary>
/// Removes the last element from an array and returns it.
/// </summary>
/// <remarks>
/// If the array is empty, null is returned.
/// </remarks>

public object Pop()
{
if (Count == 0)
return null;

object lastValue = InnerList[Count - 1];
RemoveAt(Count - 1);
return lastValue;
}

/// <summary>
/// Returns a new array consisting of a combination of two or more
/// arrays.
/// </summary>

public JArray Concat(params object[] values)
{
JArray newArray = new JArray(this);

if (values != null)
{
foreach (object value in values)
{
JArray arrayValue = value as JArray;

if (arrayValue != null)
{
foreach (object arrayValueValue in arrayValue)
newArray.Push(arrayValueValue);
}
else
{
newArray.Push(value);
}
}
}

return newArray;
}

/// <summary>
/// Removes the first element from an array and returns it.
/// </summary>

public object Shift()
{
if (Count == 0)
return null;

object firstValue = InnerList[0];
RemoveAt(0);
return firstValue;
}

/// <summary>
/// Returns an array with specified elements inserted at the beginning.
/// </summary>
/// <remarks>
/// The unshift method inserts elements into the start of an array, so
/// they appear in the same order in which they appear in the argument
/// list.
/// </remarks>

public JArray Unshift(object value)
{
List.Insert(0, value);
return this;
}

/// <summary>
/// Returns an array with specified elements inserted at the beginning.
/// </summary>
/// <remarks>
/// The unshift method inserts elements into the start of an array, so
/// they appear in the same order in which they appear in the argument
/// list.
/// </remarks>

public JArray Unshift(params object[] values)
{
if (values != null)
{
foreach (object value in values)
Unshift(value);
}

return this;
}
}
}
Loading