forked from WorkMaze/JUST.net
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSeason.cs
42 lines (35 loc) · 1.08 KB
/
Season.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JUST.NET.Test
{
public class Season
{
public static string findseason(string leafColour, string flowerColour)
{
if (leafColour == "green" && flowerColour == "red")
return "summer";
else
return "winter";
}
public static object serialize(string inObj)
{
JObject jObj = JObject.FromObject( JsonConvert.DeserializeObject(inObj));
JArray array = new JArray();
foreach(JProperty property in jObj.Children())
{
JObject nameValObj = new JObject();
nameValObj.Add("name", property.Name);
nameValObj.Add("value", property.Value);
array.Add(nameValObj);
}
JObject returnObj = new JObject();
returnObj.Add("namevaluecollection",array);
return returnObj;
}
}
}