Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
I3csstatus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jiří Kalvoda
I3csstatus
Commits
241675d0
Commit
241675d0
authored
2 years ago
by
Jiří Kalvoda
Browse files
Options
Downloads
Patches
Plain Diff
StatusBarI3: Remove null from JSON
parent
2b39ea5e
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Program.cs
+16
-1
16 additions, 1 deletion
Program.cs
with
16 additions
and
1 deletion
Program.cs
+
16
−
1
View file @
241675d0
...
@@ -29,6 +29,21 @@ namespace i3csstatus {
...
@@ -29,6 +29,21 @@ namespace i3csstatus {
return
kill
(
p
.
Id
,
sig
);
return
kill
(
p
.
Id
,
sig
);
}
}
}
}
static
class
JsonExtended
{
public
static
JsonObject
RemoveNull
(
this
JsonObject
o
)
{
List
<
string
>
toDelete
=
new
();
foreach
(
var
(
k
,
v
)
in
o
)
{
if
(
v
==
null
)
toDelete
.
Add
(
k
);
}
foreach
(
var
k
in
toDelete
)
o
.
Remove
(
k
);
return
o
;
}
}
static
class
ColorToHexExtended
static
class
ColorToHexExtended
{
{
static
public
string
ToHex
(
this
Color
c
)
static
public
string
ToHex
(
this
Color
c
)
...
@@ -348,7 +363,7 @@ namespace i3csstatus {
...
@@ -348,7 +363,7 @@ namespace i3csstatus {
[
"full_text"
]
=
e
.
text
,
[
"full_text"
]
=
e
.
text
,
[
"short_text"
]
=
e
.
short_text
,
[
"short_text"
]
=
e
.
short_text
,
[
"color"
]
=
e
.
color
?.
ToHex
(),
[
"color"
]
=
e
.
color
?.
ToHex
(),
}).
ToArray
());
}
.
RemoveNull
()
).
ToArray
());
var
opt
=
new
JsonSerializerOptions
();
var
opt
=
new
JsonSerializerOptions
();
opt
.
DefaultIgnoreCondition
=
System
.
Text
.
Json
.
Serialization
.
JsonIgnoreCondition
.
WhenWritingNull
;
opt
.
DefaultIgnoreCondition
=
System
.
Text
.
Json
.
Serialization
.
JsonIgnoreCondition
.
WhenWritingNull
;
w
.
Write
(
","
);
w
.
Write
(
","
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment