Skip to content

Commit

Permalink
Merge branch 'release/0.16.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
devlead committed Jan 22, 2020
2 parents 46897c8 + 3398591 commit 4c9ad30
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 19 deletions.
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ os:
- osx
- linux

# Ubuntu 14.04
# Ubuntu 18.04 LTS
sudo: required
dist: trusty
dist: bionic

# OS X 10.12
osx_image: xcode9.2
# OS X 10.14
osx_image: xcode11.3

mono:
- 4.4.2

dotnet: 3.0.100
dotnet: 3.0.101

before_install:
- git fetch --unshallow # Travis always does a shallow clone, but GitVersion needs the full history including branches and tags
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Notation) strings.
| Build server | Platform | Build status |
|-----------------------------|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| AppVeyor | Windows | [![AppVeyor branch](https://img.shields.io/appveyor/ci/litjson/litjson/develop.svg)](https://ci.appveyor.com/project/litjson/litjson/branch/develop) |
| Bitrise | MacOS | [![Build Status](https://www.bitrise.io/app/5975a00ca2666fb1/status.svg?token=OZnv4YWRw71IVax38Wi50Q&branch=develop)](https://www.bitrise.io/app/5975a00ca2666fb1) |
| Bitrise | Linux | [![Build Status](https://www.bitrise.io/app/4c9ee62c6ba13630/status.svg?token=RBH8UKw-68lQYjageT8VoQ&branch=develop)](https://www.bitrise.io/app/4c9ee62c6ba13630) |
| Bitrise | MacOS | [![Build Status](https://app.bitrise.io/app/5975a00ca2666fb1/status.svg?token=OZnv4YWRw71IVax38Wi50Q&branch=develop)](https://app.bitrise.io/app/5975a00ca2666fb1) |
| Bitrise | Linux | [![Build Status](https://app.bitrise.io/app/4c9ee62c6ba13630/status.svg?token=RBH8UKw-68lQYjageT8VoQ&branch=develop)](https://app.bitrise.io/app/4c9ee62c6ba13630)|
| Travis | Linux / MacOS | [![Travis build status](https://travis-ci.org/LitJSON/litjson.svg?branch=develop)](https://travis-ci.org/LitJSON/litjson) |


Expand All @@ -40,7 +40,7 @@ Code can be compiled using .NET CLI or by launching the bootstrappers in the roo
#### Prerequisites

The bootstrappers will (locally in repo)

* Fetch and install .NET Core CLI / SDK version needed to compile LitJSON.
* Fetch and install Cake runner
* Execute build script with supplied target (`--target=[Target]`) or by default
Expand All @@ -49,7 +49,7 @@ The bootstrappers will (locally in repo)
1. Build
1. Run unit tests
1. Create NuGet package

#### Testing

This library comes with a set of unit tests using the [NUnit][nunit]
Expand Down
4 changes: 2 additions & 2 deletions build.config
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash
CAKE_VERSION=0.35.0
DOTNET_VERSION=3.0.100
CAKE_VERSION=0.36.0
DOTNET_VERSION=3.0.101
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"src"
],
"sdk": {
"version": "3.0.100"
"version": "3.0.101"
}
}
2 changes: 2 additions & 0 deletions src/LitJson/JsonMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,8 @@ private static object ReadValue (Type inst_type, JsonReader reader)
list = new ArrayList ();
elem_type = inst_type.GetElementType ();
}

list.Clear();

while (true) {
object item = ReadValue (elem_type, reader);
Expand Down
6 changes: 3 additions & 3 deletions src/LitJson/LitJSON.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
</PropertyGroup>

<ItemGroup Condition="'$(OS)' == 'Windows_NT'">
<PackageReference Include="SourceLink.Create.GitHub" Version="2.8.1" PrivateAssets="All" />
<DotNetCliToolReference Include="dotnet-sourcelink-git" Version="2.8.1" />
<DotNetCliToolReference Include="dotnet-sourcelink" Version="2.8.1" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<DotNetCliToolReference Include="dotnet-sourcelink-git" Version="2.8.3" />
<DotNetCliToolReference Include="dotnet-sourcelink" Version="2.8.3" />
</ItemGroup>

<PropertyGroup>
Expand Down
48 changes: 44 additions & 4 deletions test/JsonMapperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,17 @@ public class NullableEnumTest
public NullableEnum? TestEnum;
}

class EmptyArrayInJsonDataTest
{
public int[] array;
public string name;
}

class EmptyArrayInJsonDataTestWrapper
{
public JsonData data = null;
}

[TestFixture]
public class JsonMapperTest
{
Expand Down Expand Up @@ -310,13 +321,13 @@ public void ExportEnumsTest ()
public void ExportEnumDictionaryTest()
{
Dictionary<Planets, int> planets = new Dictionary<Planets, int>();

planets.Add(Planets.Jupiter, 5);
planets.Add(Planets.Saturn, 6);
planets.Add(Planets.Uranus, 7);
planets.Add(Planets.Neptune, 8);
planets.Add(Planets.Pluto, 9);

string json = JsonMapper.ToJson(planets);

Assert.AreEqual("{\"Jupiter\":5,\"Saturn\":6,\"Uranus\":7,\"Neptune\":8,\"Pluto\":9}", json);
Expand Down Expand Up @@ -417,7 +428,7 @@ public void ExportValueTypesTest ()
test.TestUInt = 90000000;
test.TestULong = 0xFFFFFFFFFFFFFFFF; // = =18446744073709551615
test.TestDateTimeOffset =
new DateTimeOffset(2019, 9, 18, 16, 47,
new DateTimeOffset(2019, 9, 18, 16, 47,
50, 123, TimeSpan.FromHours(8)).AddTicks(4567);

string json = JsonMapper.ToJson (test);
Expand Down Expand Up @@ -871,7 +882,7 @@ public void ImportValueTypesTest ()
Assert.AreEqual (90000000, test.TestUInt, "A8");
Assert.AreEqual (18446744073709551615L, test.TestULong, "A9");
Assert.AreEqual(
new DateTimeOffset(2019, 9, 18, 16, 47,
new DateTimeOffset(2019, 9, 18, 16, 47,
50, 123, TimeSpan.FromHours(8)).AddTicks(4567),
test.TestDateTimeOffset, "A10");
}
Expand Down Expand Up @@ -1059,5 +1070,34 @@ public void NullableEnumExportTest()
expectedJson = "{\"TestEnum\":null}";
Assert.AreEqual(expectedJson, JsonMapper.ToJson(value));
}

[Test]
public void EmptyArrayInJsonDataExportTest()
{
string testJson = @"
{
""data"":
{
""array"": [],
""name"": ""testName""
}
}";

var response = JsonMapper.ToObject<EmptyArrayInJsonDataTestWrapper>(testJson);
var toJsonResult = response.data.ToJson();
string expectedJson = "{\"array\":[],\"name\":\"testName\"}";
Assert.AreEqual(toJsonResult, expectedJson);
}

[Test]
public void EmptyArrayInJsonDataTest()
{
var toJsonResult = JsonMapper.ToJson(new EmptyArrayInJsonDataTest {
name = "testName",
array = new int[0]
});
string expectedJson = "{\"array\":[],\"name\":\"testName\"}";
Assert.AreEqual(toJsonResult, expectedJson);
}
}
}

0 comments on commit 4c9ad30

Please sign in to comment.