• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

samsmithnz / GitHubActionsDotNet / 7900757945

14 Feb 2024 11:53AM CUT coverage: 76.33%. Remained the same
7900757945

Pull #133

github

web-flow
Merge 652e32ffc into 5ca82b379
Pull Request #133: Bump the core group in /src/GitHubActionsDotNet with 1 update

144 of 222 branches covered (64.86%)

Branch coverage included in aggregate %.

559 of 699 relevant lines covered (79.97%)

13.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

62.5
/src/GitHubActionsDotNet/Serialization/JSONSerialization.cs
1
using System.IO;
2
using System.Text.Json;
3
using YamlDotNet.Serialization;
4

5
namespace GitHubActionsDotNet.Serialization
6
{
7
    public static class JsonSerialization
8
    {
9
        public static JsonElement DeserializeStringToJsonElement(string yaml)
10
        {
11
            //This looks inefficient, but helps to ensure the Yaml is clean and well formed
12
            //first we convert the yaml to a object 
13
            StringReader sr = new StringReader(yaml);
31✔
14
            Deserializer deserializer = new Deserializer();
31✔
15
            object yamlObject = deserializer.Deserialize(sr);
31✔
16
            //then convert the object back to yaml again to format the yaml
17
            string processedYaml = JsonSerializer.Serialize(yamlObject);
31✔
18
            //Finally we can return a JsonElement object from the processed Yaml. 
19
            return JsonSerializer.Deserialize<JsonElement>(processedYaml);
31✔
20
        }
21

22
        //From: https://stackoverflow.com/a/36125258/337421
23
        public static bool JsonCompare(this object obj, object another)
24
        {
25
            //Serialize two objects as strings
26
            string objJson = JsonSerializer.Serialize(obj);
×
27
            string anotherJson = JsonSerializer.Serialize(another);
×
28
            //Compare the strings
29
            return objJson == anotherJson;
×
30
        }
31
    }
32
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc