From 9de13f6a37ea42dee9f4b9ee821c597eb8963637 Mon Sep 17 00:00:00 2001 From: Mattias Karlsson Date: Mon, 21 Oct 2019 17:32:39 +0200 Subject: [PATCH 1/7] Update to Ubuntu bionic & macOS 10.14 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ffabc442..f9effb3f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ os: # Ubuntu 14.04 sudo: required -dist: trusty +dist: bionic # OS X 10.12 osx_image: xcode9.2 From 6ddf16e2facfeddec10766721b163074829a8d05 Mon Sep 17 00:00:00 2001 From: Mattias Karlsson Date: Mon, 21 Oct 2019 17:33:38 +0200 Subject: [PATCH 2/7] Update to macOS 10.14 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f9effb3f..679f86e0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ sudo: required dist: bionic # OS X 10.12 -osx_image: xcode9.2 +osx_image: xcode11.2 mono: - 4.4.2 From fb2f1041a80eb6ea28f147e15d90052cd66adf5c Mon Sep 17 00:00:00 2001 From: kdw9502 Date: Fri, 17 Jan 2020 12:04:06 +0900 Subject: [PATCH 3/7] Fix empty array ToJson issues --- src/LitJson/JsonMapper.cs | 2 ++ test/JsonMapperTest.cs | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/LitJson/JsonMapper.cs b/src/LitJson/JsonMapper.cs index 5cd9268a..9a7df3ed 100644 --- a/src/LitJson/JsonMapper.cs +++ b/src/LitJson/JsonMapper.cs @@ -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); diff --git a/test/JsonMapperTest.cs b/test/JsonMapperTest.cs index a980cfa4..0f4cb895 100644 --- a/test/JsonMapperTest.cs +++ b/test/JsonMapperTest.cs @@ -202,6 +202,17 @@ public class NullableEnumTest public NullableEnum? TestEnum; } + class EmptyArrayInJsonDataTest + { + public int[] array; + public string name; + } + + class EmptyArrayInJsonDataTestWrapper + { + public JsonData data; + } + [TestFixture] public class JsonMapperTest { @@ -1059,5 +1070,23 @@ 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(testJson); + var toJsonResult = response.data.ToJson(); + string expectedJson = "{\"array\":[],\"name\":\"testName\"}"; + Assert.AreEqual(toJsonResult, expectedJson); + } } } From 2f909648f19dfe5a83c20744e76d54f3e60423b2 Mon Sep 17 00:00:00 2001 From: Mattias Karlsson Date: Wed, 22 Jan 2020 11:22:13 +0100 Subject: [PATCH 4/7] Update to .NET Core SDK 3.1.101 & Cake 0.36.0 --- .travis.yml | 8 ++++---- build.config | 4 ++-- global.json | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 679f86e0..28534d4a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,17 +3,17 @@ os: - osx - linux -# Ubuntu 14.04 +# Ubuntu 18.04 LTS sudo: required dist: bionic -# OS X 10.12 -osx_image: xcode11.2 +# OS X 10.14 +osx_image: xcode11.3 mono: - 4.4.2 -dotnet: 3.0.100 +dotnet: 3.1.101 before_install: - git fetch --unshallow # Travis always does a shallow clone, but GitVersion needs the full history including branches and tags diff --git a/build.config b/build.config index b60a6372..9c79f1e1 100644 --- a/build.config +++ b/build.config @@ -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.1.101 diff --git a/global.json b/global.json index 052baf7d..70892770 100644 --- a/global.json +++ b/global.json @@ -3,6 +3,6 @@ "src" ], "sdk": { - "version": "3.0.100" + "version": "3.1.101" } } \ No newline at end of file From 50613f3a5e0a01fe8a52b210835d7fe035d61eb9 Mon Sep 17 00:00:00 2001 From: Mattias Karlsson Date: Wed, 22 Jan 2020 11:46:24 +0100 Subject: [PATCH 5/7] Switch to Microsoft.SourceLink.GitHub and .NET Core 3.0.101 --- .travis.yml | 2 +- build.config | 2 +- global.json | 2 +- src/LitJson/LitJSON.csproj | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 28534d4a..0c6668ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ osx_image: xcode11.3 mono: - 4.4.2 -dotnet: 3.1.101 +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 diff --git a/build.config b/build.config index 9c79f1e1..71d7b946 100644 --- a/build.config +++ b/build.config @@ -1,3 +1,3 @@ #!/usr/bin/env bash CAKE_VERSION=0.36.0 -DOTNET_VERSION=3.1.101 +DOTNET_VERSION=3.0.101 diff --git a/global.json b/global.json index 70892770..c890fe9b 100644 --- a/global.json +++ b/global.json @@ -3,6 +3,6 @@ "src" ], "sdk": { - "version": "3.1.101" + "version": "3.0.101" } } \ No newline at end of file diff --git a/src/LitJson/LitJSON.csproj b/src/LitJson/LitJSON.csproj index 6b6b8535..759de5be 100644 --- a/src/LitJson/LitJSON.csproj +++ b/src/LitJson/LitJSON.csproj @@ -11,9 +11,9 @@ - - - + + + From 791815ba498de7fef810133d07e79179dd983886 Mon Sep 17 00:00:00 2001 From: Mattias Karlsson Date: Wed, 22 Jan 2020 12:03:39 +0100 Subject: [PATCH 6/7] Add missing test & address compiler warning --- test/JsonMapperTest.cs | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/test/JsonMapperTest.cs b/test/JsonMapperTest.cs index 0f4cb895..63ee5c33 100644 --- a/test/JsonMapperTest.cs +++ b/test/JsonMapperTest.cs @@ -210,7 +210,7 @@ class EmptyArrayInJsonDataTest class EmptyArrayInJsonDataTestWrapper { - public JsonData data; + public JsonData data = null; } [TestFixture] @@ -321,13 +321,13 @@ public void ExportEnumsTest () public void ExportEnumDictionaryTest() { Dictionary planets = new Dictionary(); - + 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); @@ -428,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); @@ -882,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"); } @@ -1070,7 +1070,7 @@ public void NullableEnumExportTest() expectedJson = "{\"TestEnum\":null}"; Assert.AreEqual(expectedJson, JsonMapper.ToJson(value)); } - + [Test] public void EmptyArrayInJsonDataExportTest() { @@ -1082,11 +1082,22 @@ public void EmptyArrayInJsonDataExportTest() ""name"": ""testName"" } }"; - + var response = JsonMapper.ToObject(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); + } } } From 33985917eb507c6cd8c519349afcf2508d006c07 Mon Sep 17 00:00:00 2001 From: Mattias Karlsson Date: Wed, 22 Jan 2020 12:06:24 +0100 Subject: [PATCH 7/7] Fix Bitrise badges --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3ddd05f7..c409f818 100644 --- a/README.md +++ b/README.md @@ -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) | @@ -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 @@ -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]