Skip to content

add const access#20

Merged
jart merged 1 commit intojart:mainfrom
ahgamut:const-access
Apr 8, 2026
Merged

add const access#20
jart merged 1 commit intojart:mainfrom
ahgamut:const-access

Conversation

@ahgamut
Copy link
Copy Markdown
Contributor

@ahgamut ahgamut commented Apr 6, 2026

It's not really necessary, but would be nice to have. The use case for me is the JSON object being part of a struct, and I have a bunch of const methods for the outer struct.

class Foo {
   jt::Json info;

   public:
        double getObj1A() { return info["obj1"].getNumber(); } // works
        double getObj1B() const { return info["obj1"].getNumber(); } // should work with this PR
        const std::vector<jt::Json>& getObj2() const { 
            return info["obj2"].getArray(); // should work with this PR
        }
}

@jart jart merged commit ccb9195 into jart:main Apr 8, 2026
6 checks passed
@ahgamut
Copy link
Copy Markdown
Contributor Author

ahgamut commented Apr 8, 2026

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants