Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
JSON.parse vs String.substring vs String.match for fetching one value
(version: 1)
is it faster to get one value by JSON.parse() or directly via String.substring
Comparing performance of:
JSON.parse() vs String.substring vs String.match
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
var ob = `{"aenderungen":[],"_id":"64c0fc4abd2c8bd76c9553f2","name":"Maxis","geburtsdatum":"2023-08-02T00:00:00.000Z","ICD10Code":"k k k k k ","position":0,"empfangsdatum":"2023-07-26T10:58:18.716Z","hinzugefügtVon":"6498bf3b2afb897aa26d18e6","infos":{"berichte":"ggg","puls":"hallo yazn "},"positionarr":[0,0],"stationen":[],"__v":0}`
Tests:
JSON.parse()
var value = JSON.parse(ob)._id;
String.substring
const value = ob.substring(25,49);
String.match
const value = ob.match(/"_id":"(\w+)"/)[1]
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
JSON.parse()
String.substring
String.match
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:137.0) Gecko/20100101 Firefox/137.0
Browser/OS:
Firefox 137 on Ubuntu
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
JSON.parse()
1504048.4 Ops/sec
String.substring
360127744.0 Ops/sec
String.match
19311402.0 Ops/sec
Related benchmarks:
substr vs JSON.parse
JSON.stringify fork, larger item
uint8Array MsgPack - json stringify vs string tostring on array
JSON.parse vs String.substring for fetching one value
cloneDeep vs structuredClone vs JSON clone
JSON.parse() vs. eval() large object
Lodash isEqual vs JSON stringify1
JSON.parse() vs. eval() large object 2
JSON.parse vs String.match for fetching one value
Comments
Confirm delete:
Do you really want to delete benchmark?