Sample Header Ad - 728x90

If I have a json string how do I calculate the number of bytes needed when stored?

0 votes
1 answer
1666 views
I have a json string formatted displayed in a web page. What I am trying to understand is what is the size in terms of bytes that this json string requires. If I copy and pipe to wc -c I get 1000 which is the number of characters but I don't think that this means that the json string is 1000 bytes as I have seen googling around as a suggestion. The reason I am confused is the following: In java for instance a String is composed of char and each char is 2 bytes to support utf-8. Json also supports utf-8 so I am not sure if I should consider that the size of the json string requires 2000 bytes or what is a way to figure this out?
Asked by Jim (1479 rep)
Feb 22, 2024, 06:27 PM
Last activity: Mar 1, 2024, 09:17 PM