Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get value from String-Json object

I have big String (which is not converted JSON):

{
  "MyType" : "5",
  "creationTime" : "06/03/2021 11:14:37",
  "entityCompositeKey" : "3001v4",
  ...
}

which another thousand lines.

I am only interested in value which is in MyType, I don't care about other values.

JSONObject jsonObj = new JSONObject(view);
String chiupType = jsonObj.get("MyType").toString();

but it's way too slow. What is the fastest way to get only one value from String(JSON)?

like image 516
Michu93 Avatar asked Jul 07 '26 14:07

Michu93


1 Answers

In the implementation, the whole JSON string is processed directly after the constructor has been called. Thus, there is no possibility to read out only a single value.

like image 53
flakeio Avatar answered Jul 10 '26 08:07

flakeio



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!