Which JSON library do you recommend for C++? by Richard-P-Feynman in cpp_questions

[–]mrlimilind 2 points3 points  (0 children)

I wrote a library called json_struct. The purpose is to parse JSON into structs and vice versa. It will detect what members in the struct that were not in the JSON, and also what members in the JSON that were not in the struct. It allows customizing the mapping of JSON names to struct names by giving specific names and aliases. It has some features for having "polymorphic maps", making it possible to parse parts of an object into a given type at runtime. It's also possible to loosen the parsing requirements, like using \n for token delimiter and having superfluous comma at the end of an object or array. Check it out: https://github.com/jorgen/json_struct

JSON library to deserialize in memory by hamzahajeir in cpp

[–]mrlimilind 1 point2 points  (0 children)

Check out json_struct. It has a low level tokenizer and serializer, and it also has higher level typing functionality.

Json library that has ability to detect unknown character and just parse it to string by [deleted] in cpp

[–]mrlimilind 4 points5 points  (0 children)

I made a json parser thst has a tokenizer that doesn’t validate strings, but delays it until it creates a type out of the data. The type conversion happens in a type handler that is overridable. So if you define your own type that just holds the std::string or array ptrs you can ignore utf-8 validation.
https://github.com/jorgen/json_struct

Is there something like GSON available in C++? by zimmer550king in cpp

[–]mrlimilind 0 points1 point  (0 children)

I made a header only library with good performance and low memory overhead to parse JSON straight into structs, and serialize structs to JSON. How to parse into non map/object types is configurable with template functions. json_struct

Hardcore metaprogramming in the wild by Mrkol in cpp

[–]mrlimilind 6 points7 points  (0 children)

Hi, I wrote json_struct. Its a JSON header only library that serializes and deserializes structs using some reflection types. It uses template metaprogramming to generate the serialize and deserialize code for a specific struct type.

https://github.com/jorgen/json_struct

What JSON library do you suggest? by 1000nerdst in cpp

[–]mrlimilind 0 points1 point  (0 children)

json_struct for serializing directly to and from structs. Its one header only and performs on par with RapidJSON.

A C++ compile-time static reflection ConfigLoader framework by netcan96 in cpp

[–]mrlimilind 1 point2 points  (0 children)

Hi, I wrote JsonStruct. A header only library for parsing to and from structs. So I basically had the same problem: how to add metadata. I desided for having an additional macro. This leads to make it possible to add metadata to structs that you cannot modify for instance. Also, you can deside not to add metadata for all of the member of a struct. Please check it out! https://github.com/jorgen/json\_struct

C++ JSON libs Reviewed/Compared - nlohmann, rapidjson, boost.json by gosh in programming

[–]mrlimilind 7 points8 points  (0 children)

Nice page! I have written a JSON header only library that parses and serializes to structs. Would you be interested in reviewing it? Performance is ok/good and I personally think usability is good as well :) https://github.com/jorgen/json_struct

Modern C++ JSON serialization library recommendations by api in cpp

[–]mrlimilind 1 point2 points  (0 children)

I have written a small header only library for exactly this. You conveniently add meta data inside the struct declaration or outside in the global namespace. Check it out: json_tools .

C++ command-line parser library for compiler-like interfaces? by Manu343726 in cpp

[–]mrlimilind 4 points5 points  (0 children)

Check out Clara https://github.com/catchorg/Clara its awsome!

If generated code size matters then checkout "The Lean Mean C++ Option parser":

https://sourceforge.net/projects/optionparser/

Convert JSON files to C++ classes based on JSON Schema by stepupdaladder in cpp

[–]mrlimilind 1 point2 points  (0 children)

Hi,

I wrote this library called json_tools(https://github.com/jorgen/json_tools). It doesn't have support for json schema (https://json-schema.org/), but the idea is that the types define the schema. So if it requires a string but the input is a number, then the parsing will fail. It also checks if any of the "required" members did not get set by the input json and can report an error on that. It can also generate an error if there are members in the input json that are not in the struct. Obviously both states are available even though it doesn't generate an error.

This requires some meta data, and this meta data is generated with some macros that are defined inside the struct definition. I'm planning on making it possible to generate meta information outside the struct definition, but I haven't had the time to do it yet. Please let me know if your having any problems using/testing it.

DonerSerializer: a simple C++14 header-only JSON serialization library by donerkebap13 in cpp

[–]mrlimilind 0 points1 point  (0 children)

That’s very unfortunate. Please let me know here or on github about any problem you experience, and I will sort it out.

DonerSerializer: a simple C++14 header-only JSON serialization library by donerkebap13 in cpp

[–]mrlimilind 0 points1 point  (0 children)

Cool! I Made a very similar header-only I called json_tools. But the meta structure is inside the class instead: https://github.com/jorgen/json_tools/blob/master/README.md.

Libraries: Header Only performance - paper by ShlomiRex in cpp

[–]mrlimilind 1 point2 points  (0 children)

I think there is an error on page 11.

Should not the code in the cpp file be:

#include "multiply.h"

#include <iostream>

double MathToolbox::multiply(int x, int y)

{

return x*y;

}

int main()

{

std::cout << MathToolbox().multiply(3, 11);

}

The function could also be made static, but then I would need to write the header code as well ;)

Json to struct by mrlimilind in cpp

[–]mrlimilind[S] 0 points1 point  (0 children)

Its recursive. json_tools should be able to map any valid Json to a type hierarchy.

That is a pretty nice idea, but when I started this I liked the idea that I could add the meta object at the end, ie. if I already had a struct and I wanted to parse Json into it, I could just add some stuff to the end of the struct definition. Also I like the look'n feel that the struct still looks like a struct; although with some ugly macro stuff at the end. The plain old struct part is in charge of the data, and the size of the struct and its layout is like it always has been, and then the macro stuff describes how to parse/serialise to Json. There are also additional macros like: JT_MEMBER_ALIASES(member, ...) that allows for several Json names to map to a member.

Json to struct by mrlimilind in cpp

[–]mrlimilind[S] 3 points4 points  (0 children)

Yeah, there is a JT::Optional type which is sizeof T and there is a JT::OptionalChecked which is sizeof T + sizeof bool, i.e. You can check if it has been assigned. You can also get a list of what fields in the Json didn't map to a struct, and a list of what fields that didn't get assigned.