# Read/write JSON to/from TObject

**URL:** <https://root-forum.cern.ch/t/read-write-json-to-from-tobject/63576>\
**Category:** ROOT\
**Created:** [May 19, 2025, 9:11am UTC](https://root-forum.cern.ch/t/read-write-json-to-from-tobject/63576 "2025-05-19T09:11:59Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![jb023](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/7c8e57/32.png) [@jb023](https://root-forum.cern.ch/u/jb023)\
**Post date:** [May 19, 2025, 1:03pm UTC](https://root-forum.cern.ch/t/read-write-json-to-from-tobject/63576/4 "2025-05-19T13:03:04Z")

</div>

Thanks @linev. (I incorrectly thought I could import any arbitrary JSON and it would get populated into a blank TObject, but this is wrong, my bad).

BTW when using `nlohmann::json`, I get this error on Windows with VS 2022 + root\_v6.32.12:

```auto
In file included from libtest dictionary payload:5:
In file included from E:/projects/src\Instrument.h:4:
In file included from C:/Program Files/root_v6.32.12\include\nlohmann/json.hpp:2440:
In file included from C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.43.34808\include\cassert:9:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\assert.h:12:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\corecrt.h:205:12: error: redefinition of '_CrtEnableIf<true, _Ty>'
    struct _CrtEnableIf<true, _Ty>
           ^ ~~~~~~~~~~~~~~~~~~~~~~

```

and lots of

```auto
==========================================
=============== STACKTRACE ===============
==========================================

================ Thread 0 ================
  libCore!TWinNTSystem::DispatchSignals()
  ucrtbase!seh_filter_exe()
  test!??
  VCRUNTIME140!_C_specific_handler()
  ntdll!_chkstk()
  ntdll!RtlRaiseException()

```

I found a temporary fix by editing nlohmann `json.hpp` around line 2440 into:

```auto
// allow overriding assert
#if !defined(JSON_ASSERT)
    //#include <cassert> // assert
    //#define JSON_ASSERT(x) assert(x)
    #define JSON_ASSERT(x)
#endif

```

Is there another way than this temporary fix?

Thank you again!

---

_[View the full topic](https://root-forum.cern.ch/t/read-write-json-to-from-tobject/63576)._
