Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
7ed980e
Update extern/utils subproject commit
riccardodebenedictis Feb 9, 2024
9fc0f1c
Update CMakeLists.txt and json.hpp
riccardodebenedictis Feb 9, 2024
1beca5f
Add build status badge to README
riccardodebenedictis Feb 9, 2024
5668a7d
Add compiler flags for debugging and coverage
riccardodebenedictis Feb 10, 2024
6a1d379
Add coverage support for Debug builds on Ubuntu
riccardodebenedictis Feb 10, 2024
eb84901
Update extern/utils subproject commit
riccardodebenedictis Feb 26, 2024
f7ec405
Update extern/utils subproject commit
riccardodebenedictis Feb 26, 2024
180c70b
Add option to include utils library in CMakeLists.txt
riccardodebenedictis Mar 2, 2024
340dc32
Update extern/utils subproject commit
riccardodebenedictis Mar 2, 2024
6896941
Update extern/utils subproject commit
riccardodebenedictis Mar 4, 2024
2581af1
Update extern/utils subproject commit
riccardodebenedictis Mar 9, 2024
9daea9f
Update extern/utils subproject commit
riccardodebenedictis Mar 11, 2024
2244f31
Update extern/utils subproject commit
riccardodebenedictis Mar 11, 2024
67f7cc5
Update actions/checkout to v4
riccardodebenedictis Mar 20, 2024
e1adae8
Refactor CMakeLists.txt to use separate library name and update targe…
riccardodebenedictis Mar 25, 2024
0b194a9
Update CMake build configuration and subproject commit reference
riccardodebenedictis Mar 25, 2024
a214339
Update build workflow and test configuration
riccardodebenedictis Mar 25, 2024
fa89801
Update build command to include build type configuration
riccardodebenedictis Mar 25, 2024
d2532c2
Update extern/utils subproject commit
riccardodebenedictis Mar 25, 2024
02bd511
Update extern/utils subproject commit
riccardodebenedictis Mar 25, 2024
005f4e5
Update extern/utils subproject commit hash
riccardodebenedictis Mar 27, 2024
262bdcb
Update extern/utils subproject commit
riccardodebenedictis Mar 27, 2024
17a4a75
Update CMake workflow to include memory sanitizer and valgrind***
riccardodebenedictis Mar 28, 2024
8c66074
Update extern/utils subproject commit
riccardodebenedictis Mar 28, 2024
67a0b13
Update CMake workflow and submodules
riccardodebenedictis Mar 28, 2024
ec4304f
Update extern/utils subproject commit
riccardodebenedictis Mar 28, 2024
7c7a5e1
Update extern/utils subproject commit hash
riccardodebenedictis Apr 9, 2024
6bfba45
Update extern/utils subproject commit hash
riccardodebenedictis Apr 9, 2024
0fc6772
Update extern/utils subproject commit hash
riccardodebenedictis Apr 11, 2024
dd25d07
Update extern/utils subproject commit hash
riccardodebenedictis Apr 12, 2024
a0f50ee
Update extern/utils subproject commit hash
riccardodebenedictis Apr 15, 2024
10f6ba9
Update extern/utils subproject commit hash
riccardodebenedictis Apr 19, 2024
e111cff
Update extern/utils subproject commit hash
riccardodebenedictis Apr 19, 2024
d23ca9e
Update extern/utils subproject commit hash
riccardodebenedictis Apr 20, 2024
fd9c18a
Update extern/utils subproject commit hash
riccardodebenedictis Apr 21, 2024
47c2221
Update dependencies installation command in .github/workflows/cmake.yml
riccardodebenedictis Apr 21, 2024
c43ba8b
Refactor CMakeLists.txt to conditionally add the utils subdirectory
riccardodebenedictis Apr 22, 2024
f0acd66
Refactor CMakeLists.txt to conditionally add the utils subdirectory a…
riccardodebenedictis Apr 22, 2024
a450eda
Update extern/utils subproject commit hash
riccardodebenedictis Apr 22, 2024
5fbf126
Update extern/utils subproject commit hash
riccardodebenedictis Apr 22, 2024
5a558ed
Update extern/utils subproject commit hash
riccardodebenedictis Apr 22, 2024
77a8b43
Refactor json.hpp and json.cpp to improve code organization and reada…
riccardodebenedictis May 6, 2024
0096812
Refactor json.hpp and json.cpp for improved code organization and rea…
riccardodebenedictis May 6, 2024
5b6a5c7
Refactor to_array function in json.hpp and json.cpp for improved code…
riccardodebenedictis May 6, 2024
1589eb4
Refactor test_json.cpp for using variant
riccardodebenedictis May 9, 2024
9819032
Refactor code for improved organization and readability
riccardodebenedictis May 9, 2024
9ca9682
Refactor json.hpp to use uint64_t instead of u_int64_t for improved c…
riccardodebenedictis May 9, 2024
8dfae83
Refactor json.hpp to use int64_t instead of int for improved code con…
riccardodebenedictis May 9, 2024
a737938
Refactor json.hpp and json.cpp to use int64_t for improved code consi…
riccardodebenedictis May 9, 2024
813ace6
Refactor json.hpp constructor to use int64_t for improved code consis…
riccardodebenedictis May 9, 2024
f02aa8d
Added vector constructor
riccardodebenedictis May 9, 2024
64ba080
Refactor code for improved consistency and readability
riccardodebenedictis May 9, 2024
9924834
Refactor json.hpp constructor to use initializer list for improved co…
riccardodebenedictis May 13, 2024
c1413c1
Refactor json.hpp constructor to use initializer list for improved co…
riccardodebenedictis May 13, 2024
81b02a8
Refactor json.cpp to remove unnecessary logging statement
riccardodebenedictis May 13, 2024
be1db89
Add badges for build status and code coverage
riccardodebenedictis May 14, 2024
ea8cde6
Added tests for constructors..
riccardodebenedictis May 14, 2024
747a3c7
Solved minor test issue..
riccardodebenedictis May 14, 2024
e3d266b
Added some tests to improve coverage..
riccardodebenedictis May 14, 2024
8df0827
Refactor extern/utils subproject commit
riccardodebenedictis May 16, 2024
1709a6c
Add include for cstdint in json.hpp
riccardodebenedictis May 16, 2024
6d37db5
Added JSON schema validation..
riccardodebenedictis Jul 1, 2024
b1228bf
Refactor json.cpp to use int64_t for schema minimum and maximum values
riccardodebenedictis Jul 1, 2024
0cd3490
Refactor JSON schema validation code for improved readability and mai…
riccardodebenedictis Jul 1, 2024
6c2d033
Refactor JSON object access and initialization
riccardodebenedictis Sep 7, 2024
55cf7d7
Refactor JSON object access and initialization to include schema vali…
riccardodebenedictis Oct 4, 2024
3aa6a4c
Refactor JSON schema validation code to use uint64_t for minimum and …
riccardodebenedictis Oct 4, 2024
2e5ca0e
Refactor JSON value to string conversion for improved readability and…
riccardodebenedictis Oct 21, 2024
50e558f
Refactor JSON value to string conversion for improved readability and…
riccardodebenedictis Oct 21, 2024
159dc90
Refactor extern/utils submodule to use updated commit
riccardodebenedictis Oct 24, 2024
dbbbf3f
Update subproject commit reference
riccardodebenedictis Oct 24, 2024
4b4efce
Merge branch 'memory' of https://github.com/ratioSolver/json into memory
riccardodebenedictis Oct 24, 2024
336435c
Update extern/utils submodule to latest commit
riccardodebenedictis Oct 31, 2024
3c5562f
Update extern/utils submodule to latest commit
riccardodebenedictis Nov 5, 2024
aa602f2
Update extern/utils submodule to latest commit
riccardodebenedictis Nov 11, 2024
4656f8c
Update extern/utils submodule to latest commit
riccardodebenedictis Nov 11, 2024
6da0457
Add <string_view> include to json.hpp
riccardodebenedictis Nov 11, 2024
bf350db
Remove redundant <iostream> include from json.cpp and add it to json.hpp
riccardodebenedictis Nov 11, 2024
66b2a9d
Update extern/utils submodule to latest commit
riccardodebenedictis Nov 20, 2024
485fb4c
Update extern/utils submodule to latest commit
riccardodebenedictis Dec 16, 2024
99964c9
Update extern/utils submodule to latest commit
riccardodebenedictis Jan 7, 2025
9467b8b
Enhance test executable configuration with compiler warnings and cove…
riccardodebenedictis Jan 14, 2025
1eaba66
Refactor CMake configuration to use setup_sanitizers and update exter…
riccardodebenedictis Jan 15, 2025
616b008
Update extern/utils submodule to latest commit
riccardodebenedictis Jan 15, 2025
d9c835b
Update extern/utils submodule to latest commit
riccardodebenedictis Jan 15, 2025
436acb0
Update extern/utils submodule and refactor json class constructors to…
riccardodebenedictis Jan 15, 2025
e79c1a6
Add overload for load function to accept std::string_view
riccardodebenedictis Jan 15, 2025
31845b6
Refactor load function to accept std::string_view and remove char* ov…
riccardodebenedictis Jan 15, 2025
1bb4451
Update GitHub Actions workflow for multi-platform builds and enhance …
riccardodebenedictis Jan 17, 2025
ff7f369
Update CMakeLists.txt to ensure utils dependency is always added and …
riccardodebenedictis Jan 17, 2025
a275982
Update extern/utils submodule to latest commit
riccardodebenedictis Jan 17, 2025
df27630
Update extern/utils submodule to latest commit
riccardodebenedictis Jan 17, 2025
8ede303
Update CMake minimum version and refresh extern/utils submodule
riccardodebenedictis Jan 17, 2025
01b04e1
Remove undefined behavior sanitizer flag from CMake and update extern…
riccardodebenedictis Jan 17, 2025
4525aad
Update extern/utils submodule to latest commit
riccardodebenedictis Jan 23, 2025
f8d12b1
Update extern/utils submodule to latest commit
riccardodebenedictis Jan 23, 2025
5833549
Update extern/utils submodule to latest commit
riccardodebenedictis Jan 25, 2025
fabeb88
Update extern/utils submodule to latest commit
riccardodebenedictis Jan 25, 2025
19fb763
Update extern/utils submodule to latest commit
riccardodebenedictis Jan 25, 2025
043441b
Update extern/utils submodule to latest commit
riccardodebenedictis Jan 27, 2025
8030eb3
Update extern/utils submodule to latest commit
riccardodebenedictis Jan 27, 2025
449e0ee
Update extern/utils submodule to latest commit
riccardodebenedictis Jan 27, 2025
69f2f7f
Update extern/utils submodule to latest commit
riccardodebenedictis Jan 27, 2025
9e68394
Update extern/utils submodule to latest commit
riccardodebenedictis Jan 29, 2025
d1d768d
Update extern/utils submodule to latest commit
riccardodebenedictis Jan 29, 2025
20cd1c4
Update extern/utils submodule to latest commit
riccardodebenedictis Jan 31, 2025
e9aad3e
Update extern/utils submodule to latest commit
riccardodebenedictis Feb 4, 2025
f3fd8ef
Update extern/utils submodule to latest commit
riccardodebenedictis Feb 7, 2025
2d7068d
Update extern/utils submodule to latest commit
riccardodebenedictis Feb 7, 2025
b694d70
Update extern/utils submodule to latest commit
riccardodebenedictis Feb 8, 2025
bca0e46
Update extern/utils submodule to latest commit
riccardodebenedictis Feb 8, 2025
fdec1d1
Update extern/utils submodule to latest commit
riccardodebenedictis Feb 10, 2025
ba9ee6c
Update extern/utils submodule to latest commit
riccardodebenedictis Feb 13, 2025
998b825
Update extern/utils submodule to latest commit
riccardodebenedictis Feb 21, 2025
0a54930
Add whitespace handling for JSON array parsing
riccardodebenedictis Mar 27, 2025
3225015
Update extern/utils submodule to latest commit
riccardodebenedictis Apr 1, 2025
1964cf0
Update extern/utils submodule to latest commit
riccardodebenedictis Apr 1, 2025
553256c
Update extern/utils submodule to latest commit
riccardodebenedictis Apr 14, 2025
036cfd3
Update extern/utils submodule to latest commit
riccardodebenedictis May 14, 2025
e61e23b
Add type-checking methods to json class and update tests
riccardodebenedictis Jul 8, 2025
3226084
Fix brew install command to use --formula for cmake
riccardodebenedictis Jul 8, 2025
12a0ff8
Update extern/utils submodule to latest commit
riccardodebenedictis Jul 8, 2025
20c4319
Update extern/utils submodule to latest commit
riccardodebenedictis Jul 10, 2025
abe237e
Initialize json value to nullptr in constructor for json_type::object
riccardodebenedictis Jul 17, 2025
2c83ac0
Initialize json value to nullptr in constructor and handle null case …
riccardodebenedictis Jul 17, 2025
65ab59d
Refactor JSON array initialization in tests to use json constructor
riccardodebenedictis Jul 17, 2025
e7cf44d
Add move constructor to json class for efficient resource transfer
riccardodebenedictis Jul 17, 2025
a44ea46
Add constexpr specifier to JSON type check functions for improved per…
riccardodebenedictis Jul 19, 2025
f8faf04
Remove cmake installation from CI workflows to streamline dependency …
riccardodebenedictis Sep 4, 2025
89b6805
Update test step name in CI workflow for clarity
riccardodebenedictis Sep 4, 2025
6b2f6cb
Update subproject commit reference in extern/utils
riccardodebenedictis Sep 17, 2025
4a38e92
Update subproject commit reference in extern/utils
riccardodebenedictis Oct 2, 2025
174d0ba
Update subproject commit reference in extern/utils
riccardodebenedictis Oct 23, 2025
91a2228
Update subproject commit reference in extern/utils
riccardodebenedictis Oct 27, 2025
dc550ec
Update subproject commit reference in extern/utils
riccardodebenedictis Oct 31, 2025
0216df7
Update subproject commit reference in extern/utils
riccardodebenedictis Oct 31, 2025
27a9ee7
Update subproject commit reference in extern/utils
riccardodebenedictis Nov 7, 2025
6e3bc25
Update subproject commit reference in extern/utils
riccardodebenedictis Nov 15, 2025
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
148 changes: 134 additions & 14 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,149 @@ name: CMake
on: [push, pull_request]

jobs:
build:
runs-on: ${{ matrix.os }}
ubuntu-address-undefined-coverage:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
build_type: [Debug, Release]
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y lcov

- name: Configure CMake
run: cmake -B build -DCMAKE_BUILD_TYPE=Debug -DENABLE_ASAN=ON -DENABLE_UBSAN=ON -DENABLE_COV=ON

- name: Build
run: cmake --build build --config Debug

- name: Test with address sanitizer, undefined behavior sanitizer and coverage
working-directory: build
run: ctest -C Debug --rerun-failed --output-on-failure -T Test -T Coverage

- name: Make coverage report
run: |
lcov --capture --directory build --output-file coverage.info
lcov --remove coverage.info '/usr/*' --output-file coverage.info
lcov --list coverage.info

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}

ubuntu-memcheck:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y valgrind

- name: Configure CMake
run: cmake -B build -DCMAKE_BUILD_TYPE=Debug

- name: Build
run: cmake --build build --config Debug

- name: Test with memory checker
working-directory: build
run: ctest -C Debug --rerun-failed --output-on-failure -T Test -T MemCheck

windows-debug:
runs-on: windows-latest

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Configure CMake
run: cmake -B build -DCMAKE_BUILD_TYPE=Debug

- name: Build
run: cmake --build build --config Debug

- name: Test
working-directory: build
run: ctest -C Debug --rerun-failed --output-on-failure -T Test

macos-address-undefined:
runs-on: macos-latest

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Configure CMake
run: cmake -B build -DCMAKE_BUILD_TYPE=Debug -DENABLE_ASAN=ON -DENABLE_UBSAN=ON

- name: Build
run: cmake --build build --config Debug

- name: Test with address sanitizer and undefined behavior sanitizer
working-directory: build
run: ctest -C Debug --rerun-failed --output-on-failure -T Test

ubuntu-release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Configure CMake
run: cmake -B build -DCMAKE_BUILD_TYPE=Release

- name: Build
run: cmake --build build --config Release

- name: Test
working-directory: build
run: ctest -C Release --rerun-failed --output-on-failure -T Test

windows-release:
runs-on: windows-latest

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Configure CMake
run: cmake -B build -DCMAKE_BUILD_TYPE=Release

- name: Build
run: cmake --build build --config Release

- name: Test
working-directory: build
run: ctest -C Release --rerun-failed --output-on-failure -T Test

env:
BUILD_TYPE: ${{ matrix.build_type }}
macos-release:
runs-on: macos-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
run: cmake -B build -DCMAKE_BUILD_TYPE=Release

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
run: cmake --build build --config Release

- name: Test
working-directory: ${{github.workspace}}/build
run: ctest -C ${{env.BUILD_TYPE}} --rerun-failed --output-on-failure -T Test -T Coverage
working-directory: build
run: ctest -C Release --rerun-failed --output-on-failure -T Test
64 changes: 10 additions & 54 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,67 +1,23 @@
cmake_minimum_required(VERSION 3.0.0)
project(json VERSION 0.1.0)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=undefined")

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

include(GenerateExportHeader)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
cmake_minimum_required(VERSION 3.21)
project(json VERSION 0.2.0 LANGUAGES CXX)

include(CTest)
enable_testing()

option(JSON_INCLUDE_UTILS "Include utils library" ON)
if(JSON_INCLUDE_UTILS)
add_library(json src/json.cpp)
target_compile_features(json PUBLIC cxx_std_17)
target_include_directories(json PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
if(NOT TARGET utils)
add_subdirectory(extern/utils)
endif()

file(GLOB JSON_SOURCES src/*.cpp)
file(GLOB JSON_HEADERS include/*.hpp)

add_library(${PROJECT_NAME} SHARED ${JSON_SOURCES})
add_dependencies(${PROJECT_NAME} utils)
GENERATE_EXPORT_HEADER(${PROJECT_NAME})
target_include_directories(${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/include $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
target_link_libraries(${PROJECT_NAME} PUBLIC utils)
add_dependencies(json utils)
target_link_libraries(json PUBLIC utils)
setup_sanitizers(json)

if(BUILD_TESTING)
add_subdirectory(tests)
endif()

if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /W4)
else()
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic)
if (ADD_COVERAGE)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(${PROJECT_NAME} PRIVATE --coverage)
target_link_libraries(${PROJECT_NAME} PUBLIC gcov)
endif()
endif()
endif()

install(
TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(
FILES ${JSON_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/json_export.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
)
configure_package_config_file(src/${PROJECT_NAME}Config.cmake.in ${PROJECT_NAME}Config.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} PATH_VARS CMAKE_INSTALL_INCLUDEDIR)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake VERSION 1.0.0 COMPATIBILITY SameMajorVersion)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_NAME json)
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# JSON

![Build Status](https://github.com/ratioSolver/json/actions/workflows/cmake.yml/badge.svg)
[![codecov](https://codecov.io/gh/ratioSolver/json/branch/master/graph/badge.svg)](https://codecov.io/gh/ratioSolver/json)

This repository contains a [JSON](http://www.json.org/) parser and generator written in C++.

## Read a JSON from a string
Expand Down
Loading
Loading