Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
98a7073
Adapt bazel infrastructure to enable choosing json library
JuriSchroeder May 22, 2026
8891022
Add serializer files
JuriSchroeder May 26, 2026
1a15f81
Move serializer
JuriSchroeder May 27, 2026
ba4035b
Add adapter
JuriSchroeder Jun 3, 2026
7fa7701
Merge remote-tracking branch 'origin/main' into vajson-serializer
JuriSchroeder Aug 19, 2026
ca5628f
Move vajson serializer to vajson parser directory
JuriSchroeder Aug 26, 2026
a5961be
Revert "Move vajson serializer to vajson parser directory"
JuriSchroeder Aug 26, 2026
21d0e52
Add vajson as second serializer backend
JuriSchroeder Aug 26, 2026
755faa9
Remove amsr namespace; Remove VCA annotations
JuriSchroeder Aug 26, 2026
a4a6486
Merge branch 'main' into vajson-serializer
JuriSchroeder Aug 26, 2026
c6d1dee
Make functions single return
JuriSchroeder Aug 26, 2026
84b0580
Merge branch 'vajson-serializer' of github.com:JuriSchroeder/baselibs…
JuriSchroeder Aug 27, 2026
3a5bfcc
RFC compliance for JSON serializer
JuriSchroeder Sep 17, 2026
60d52d7
Remove dead code
JuriSchroeder Sep 17, 2026
42976cc
Handle bool differently
JuriSchroeder Sep 17, 2026
7750a5e
Merge remote-tracking branch 'origin/main' into vajson-serializer
JuriSchroeder Sep 17, 2026
ba1c8ff
Remove more dead code
JuriSchroeder Sep 17, 2026
35394f5
Coverage scope fix
JuriSchroeder Sep 17, 2026
42bcca8
Update README.md
JuriSchroeder Sep 17, 2026
d8be608
Format
JuriSchroeder Sep 18, 2026
9596c1a
Rewrite IsFinite
JuriSchroeder Sep 18, 2026
f747a97
Collapse nested namespaces
JuriSchroeder Sep 18, 2026
312785e
Some clang-tidy findings
JuriSchroeder Sep 18, 2026
1ec271f
Revert unrelated changes
JuriSchroeder Sep 18, 2026
e2e15df
Remove more dead code
JuriSchroeder Sep 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions score/json/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,27 @@ config_setting(
visibility = ["@score_baselibs//score/json/internal/parser:__subpackages__"],
)

string_flag(
name = "writer_library",
build_setting_default = "json_serialize",
values = [
"json_serialize",
"vajson",
],
)

config_setting(
name = "writer_library_json_serialize",
flag_values = {":writer_library": "json_serialize"},
visibility = ["@score_baselibs//score/json/internal/writer:__subpackages__"],
)

config_setting(
name = "writer_library_vajson",
flag_values = {":writer_library": "vajson"},
visibility = ["@score_baselibs//score/json/internal/writer:__subpackages__"],
)

cc_library(
name = "parser_interface",
srcs = ["i_json_parser.cpp"],
Expand Down Expand Up @@ -116,8 +137,8 @@ cc_library(
visibility = ["@score_baselibs//score/json:__subpackages__"],
deps = [
":writer_interface",
"@score_baselibs//score/json/internal/writer/json_serialize",
"@score_baselibs//score/language/safecpp/safe_math",
"@score_baselibs//score/json/internal/writer",
"@score_baselibs//score/json/internal/writer:writer_backend",
],
)

Expand Down Expand Up @@ -207,6 +228,10 @@ cc_test(
"test_warnings",
"aborts_upon_exception",
],
local_defines = select({
":writer_library_json_serialize": ["WRITER_JSON_SERIALIZE"],
":writer_library_vajson": ["WRITER_VAJSON"],
}),
tags = ["unit"],
visibility = [
"@score_baselibs//score/json:__pkg__",
Expand Down
18 changes: 16 additions & 2 deletions score/json/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
- [Requirements](#requirements)
- [Assumptions of Use](#assumptions-of-use)
- [Selecting base library](#selecting-base-library)
- [Selecting writer library](#selecting-writer-library)

This JSON library is designed as an abstraction layer which can switch to using
other parsers/serializers under the hood. At the moment it uses vaJson from Vector for parsing,
which is ASIL D certified. For serialization this library uses a custom implementation.
which is ASIL D certified. For serialization a custom implementation is used by default, with vaJson
available as an alternative, [selectable via a feature flag](#selecting-writer-library).

This library requires to be ASIL B certified, so it can be used in other ASIL B
certified components.
Expand Down Expand Up @@ -398,7 +400,7 @@ since they would require high amount of work. Please be aware and note:
For the most up to date information on Requirements please follow the provided links to CodeBeamer.

Adaptive Platform SW Safety Requirements
- [The users of the vaJson ibrary SHALL guarantee the integrity of the data used to initialize the `amsr::json::JsonData` buffer.](broken_link_c/issue/6576406)
- [The users of the vaJson Library SHALL guarantee the integrity of the data used to initialize the `score::json::vajson::JsonData` buffer.](broken_link_c/issue/6576406)

[SW Component Requirements](broken_link_c/tracker/566325?workingSetId=-1&layout_name=document&subtreeRoot=5310849)
- The JSON-Library shall support at least the functional set of RFC-8259.
Expand Down Expand Up @@ -438,3 +440,15 @@ In order to make use of nlohmann json library, feature flag needs to be set. Ple
bazel test --config=spp_host_clang //score/json/... --//score/json:base_library="nlohmann"

nlohmann json library do not supports hexadecimal. As it is not part of json standard.

## Selecting writer library

Independently of the parser, the serialization backend is selected by the `writer_library` flag. It accepts
`json_serialize` (the default, a custom implementation) and `vajson` (the vector json library). The parser flag
`base_library` has no influence on serialization.

bazel test --config=spp_host_clang //score/json/... --//score/json:writer_library="vajson"

Mind that the two backends differ in the representation they emit: `json_serialize` pretty-prints with a four
space indentation, whereas `vajson` emits compact JSON without any insignificant whitespace between tokens. Both
produce valid, equivalent JSON, but consumers comparing serialized output byte-wise are affected by the choice.
38 changes: 38 additions & 0 deletions score/json/internal/writer/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# *******************************************************************************
# Copyright (c) 2026 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

load("@rules_cc//cc:defs.bzl", "cc_library")
load("@score_baselibs//score/language/safecpp:toolchain_features.bzl", "COMPILER_WARNING_FEATURES")

# Declarations of the serialization backend seam. Exactly one backend provides the definitions; which one is
# selected by the `//score/json:writer_library` flag below.
cc_library(
name = "writer_backend",
hdrs = ["writer_backend.h"],
features = COMPILER_WARNING_FEATURES,
tags = ["FFI"],
visibility = ["@score_baselibs//score/json:__subpackages__"],
deps = [
"@score_baselibs//score/json/internal/model",
"@score_baselibs//score/result",
],
)

alias(
name = "writer",
actual = select({
"@score_baselibs//score/json:writer_library_json_serialize": "@score_baselibs//score/json/internal/writer/json_serialize:json_serialize_backend",
"@score_baselibs//score/json:writer_library_vajson": "@score_baselibs//score/json/internal/writer/vajson:vajson_backend",
}),
visibility = ["@score_baselibs//score/json:__pkg__"],
)
14 changes: 14 additions & 0 deletions score/json/internal/writer/json_serialize/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ cc_library(
],
)

cc_library(
name = "json_serialize_backend",
srcs = ["json_serialize_backend.cpp"],
features = COMPILER_WARNING_FEATURES,
tags = ["FFI"],
visibility = ["@score_baselibs//score/json/internal/writer:__pkg__"],
deps = [
":json_serialize",
"@score_baselibs//score/json/internal/writer:writer_backend",
"@score_baselibs//score/language/futurecpp",
"@score_baselibs//score/language/safecpp/safe_math",
],
)

cc_test(
name = "json_serialize_unit_test",
srcs = [
Expand Down
Loading
Loading