C++ Weekly - Ep 319 - A JSON To C++ Converter

preview_player
Показать описание
☟☟ Awesome T-Shirts! Sponsors! Books! ☟☟

Upcoming Workshops:

T-SHIRTS AVAILABLE!

WANT MORE JASON?

SUPPORT THE CHANNEL

GET INVOLVED

JASON'S BOOKS

► C++23 Best Practices

► C++ Best Practices

JASON'S PUZZLE BOOKS

► Object Lifetime Puzzlers Book 1

► Object Lifetime Puzzlers Book 2

► Object Lifetime Puzzlers Book 3

► Copy and Reference Puzzlers Book 1

► Copy and Reference Puzzlers Book 2

► Copy and Reference Puzzlers Book 3

► OpCode Puzzlers Book 1


RECOMMENDED BOOKS

AWESOME PROJECTS

O'Reilly VIDEOS

Рекомендации по теме
Комментарии
Автор

I don't know why there's all of this hate for clear enunciation and deliberate trains of thought. I watched (listened, mainly) while tending the grill on a loud windy day, so it was helpful.

On to the meat of the video, I have no idea why I might potentially use this in the future, but I do know that I've wanted something similar to this in the past. So on behalf of future me, I thank you for the extra tool on my belt for use whenever the need arises.

Phroggster
Автор

Nice. I imagine you could also make the program convert the JSON to a static class/struct and have the compilation access the data by name instead of by key.

DamianReloaded
Автор

I think this tool has so much potential, great work!

LogicEu
Автор

You should definetely rename it to JSON to CPP Turner

Woockashek
Автор

I was thinking about config/**.ini files just as you mentioned configuration files. Nice

PedroOliveira-slnw
Автор

When working with 'webpack' and other JS bundling tools, there are options for configuring transformers that pre-process imports (of any filetype theoretically, as long as you can write a transformer) into javascript code. I wonder if something like this combined with the #embed proposal could be useful? Of course, this would mean a hell of a lot more constexpr support in the compiler, and is really helped for the JS case since Node is both the target environment and the environment running the build tools.

Dth
Автор

sorry, my question iscompletely unrelated to the video, but one day I needed to reemplement the std::optional, to somewhat cover the std::optional<void> case. So I did a wrapper around std::aligned_storage, and everything seemed to be working fine, but then address sanitizer stated, that I had a bunch of "use after free" cases with that aligned storage. I started digging up the std library implementation of the optional and found out about the std::launder. I slapped that thing to my optional, and it magically fixed those uses after free. Can you clear that out for me, please? The cppref article about std::launder didn't help at all

Raspredval
Автор

The raw strings shouldn't be necessary. JSON defines member names as valid JSON strings, so that is utf8 with only a few escapes that are needed(values <0x20)

beachedwhale
Автор

A day early! I almost thought I'd gotten the day of the week wrong!

Interesting tool though, thank you!

Omnifarious
Автор

But I thought that Jason converted to C++ a long time ago

LenPopp
Автор

Since it has the same API as nlohmann, could you simply use their test suite?

muluman
Автор

Why don't you simply escape backslashes and double quotes and include your string constants into ordinary double quotes? How do you handle unicode characters?

JohnB
Автор

I’m puzzled by why I would want to specify configuration that is known at compile time in a different language. I suspect there is a good reason, but I haven’t yet found a case myself where I wasn’t better off factoring out a configuration source file in the language of the code it was configuring. What am I missing here?

alxr
Автор

So what is the use case for this? Am I correct in assuming it's just to incorporate a local JSON file into a C++ application by creating a class that has all it's data? So where would this be useful? Don't the majority of applications consume JSON at runtime? Possibly you have a web service that hits an API endpoint and gets load of data. That JSON has to be parsed at runtime.
What you can do is maybe create a structure that would hold easily that JSON (somehow) but creating this data structure for something you have locally... not seeing how useful that is to the majority of people.
If you have a massive JSON for configuration consider changing to SQLite or something.
Maybe I'm missing something here....

antoniocs
Автор

Compile time json converter is nice. But in the real world, the json files are read by the application during start up and they are converted to classes.

Normally, servers are brought up much ahead of actual business time. In that case, what advantage does this bring?

jagansai
Автор

For those of you that don't understand why this might be useful, you don't work with a resource constrained system that would clearly benefit from this. This video is not for you unless you want to play around with the techniques used or learn how to use them better. Jason mentions at least two examples where something like this could be useful.

ptikGhost
Автор

@jason: why the *_impl.hpp? Is there a reason against putting the implementation directly in the *.cpp file?

robertfrysch
Автор

What’s with all the speed comments? He’s trying to be clear and articulate.

gtdcoder
Автор

I'm one of those people who set most vids on Youtube at 2x speed. You aren't an especially slow speaker.

DS
Автор

Why do you use the ugly include guard technique from 1978 instead of #pragma once?

VioletGiraffe
visit shbcf.ru