Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the array length in nlohmann's json library?

I am using nlohmann/json lib and want to get the length of a json array. Image i have:

[
"test",
"test2"
]

and want to recieve the length (2). When i tried the .length() method, it showed me this error:

using json = using json = class nlohmann::basic_json<>' {aka 'class nlohmann::basic_json<>'} has no member named 'length

so how can I get the length in this library?

like image 568
Ank i zle Avatar asked Oct 24 '25 14:10

Ank i zle


1 Answers

You want to use myJsonArray.size() method here.

like image 149
theWiseBro Avatar answered Oct 26 '25 06:10

theWiseBro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!