Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Object literal vs JSON.parse fork
(version: 0)
As long as the JSON string is only evaluated once, the JSON.parse approach is much faster compared to the JavaScript object literal, especially for cold loads.
Comparing performance of:
Object literal test vs Json parse
Created:
4 years ago
by:
Guest
Jump to the latest result
Tests:
Object literal test
const literal = {"isProduction":true,"auth-url":"\/user\/ajax-xdm-auth\/","views":{"link":"\/ms\/views\/kolesa"},"language":"ru","staticLink":"\/\/kolesa.kz\/static\/frontend","locale":"ru_RU.UTF-8","cdn":{"cookie":"kl_cdn_host","defaultHost":"alatp-photos-kl.kcdn.kz"},"limitValues":5,"multiSelectDelimiter":",","sizeNotifications":5,"isCreditPage":false,"nameCookieByUT":"kut","hasVerifiedPhone":true,"globalUserId":561888,"listedUsersToReport":[18949883],"isNYEnabled":false,"buckyConfig":{"host":"\/ms\/rum","aggregationInterval":100,"sample":1},"buckyPrefix":"kolesa.frontend","sentryConfig":{"isEnabled":true,"blackList":"metrika,Non-Error promise rejection,partner-code-bundles,pcode,AdSDK,gtm.js,Invalid scheme,chrome-extension,anonymous,ntp is not defined,pubads,pagead,freed script,adfox,illegal character,Script error,Invalid scheme,Script error.,"},"advisory":{"url":"\/a\/ajax-advisory\/","timeoutSeconds":5,"cookieName":"promo_advisory_new","cookieDeclineTimeout":86400,"cookieApplyTimeout":86400},"guideHints":{"url":"\/ajax-get-guide-hints\/","cookiePrefix":"gh_"},"demoPackage":{"cookieName":"demo_package"},"accountFill":{"url":"https:\/\/pay.kolesa.kz\/cabinet?"},"urlToSettings":"\/passport\/settings\/","gatewayScript":{"0":"https:\/\/pay.kolesa.kz\/static\/js\/gateway\/common\/iframe-loader.js"},"paidServicesUrls":{"move-to-archive":"\/my\/ajax-move-to-archive\/"},"messagesEndpoints":{"baseUrl":"https:\/\/chat.kolesa.kz\/ms\/chat","wsConnection":"wss:\/\/ws.kolesa.kz\/v2\/connection\/websocket","getToken":"\/v2\/messages\/getTokenForClient.json","getCredentials":"\/v2\/messages\/getCredentialsForThreads.json","getThreads":"\/v1\/messages\/getAllThreads.json","getThread":"\/v1\/messages\/getThread.json","getMessage":"\/v1\/messages\/getMessage.json","blockThread":"\/v1\/messages\/blacklist\/add.json","unblockThread":"\/v1\/messages\/blacklist\/remove.json","deleteThread":"\/v1\/messages\/deleteThread.json","sendMessage":"\/v1\/messages\/send.json","markAsRead":"\/v1\/messages\/markAsRead.json","getChannelHash":"\/v1\/messages\/getChannelHash.json","getThreadIdWithSupport":"\/v1\/messages\/getThreadIdWithSupport.json"},"oaClient":"fis9f7ekamza4x12qtt7","convert":[],"priceHint":{"1":[{"to":5000},{"from":5000,"to":10000},{"from":10000,"to":15000}],"2":[{"to":"1 000 000","text":"\u0434\u043e 1 \u043c\u043b\u043d"},{"from":"1 000 000","to":"2 000 000","text":"1 \u2014 2 \u043c\u043b\u043d"},{"from":"2 000 000","to":"3 000 000","text":"2 \u2014 3 \u043c\u043b\u043d"}],"3":[{"to":5000},{"from":5000,"to":10000},{"from":10000,"to":15000}],"4":[{"to":300000},{"from":300000,"to":600000},{"from":600000,"to":900000}]},"nps":{"project":"kolesa.kz","data":[],"url":"https:\/\/kolesa.kz\/ms\/nps\/"},"userLogin":"kuzyrov@kolesa.kz","url-contents":"\/get-contents\/","route":"index:index","controller":"index","action":"index","app":"Frontend","userId":582896}; literal.priceHint[1][1].from;
Json parse
const json = JSON.parse('{"isProduction":true,"auth-url":"/user/ajax-xdm-auth/","views":{"link":"/ms/views/kolesa"},"language":"ru","staticLink":"//kolesa.kz/static/frontend","locale":"ru_RU.UTF-8","cdn":{"cookie":"kl_cdn_host","defaultHost":"alatp-photos-kl.kcdn.kz"},"limitValues":5,"multiSelectDelimiter":",","sizeNotifications":5,"isCreditPage":false,"nameCookieByUT":"kut","hasVerifiedPhone":true,"globalUserId":561888,"listedUsersToReport":[18949883],"isNYEnabled":false,"buckyConfig":{"host":"/ms/rum","aggregationInterval":100,"sample":1},"buckyPrefix":"kolesa.frontend","sentryConfig":{"isEnabled":true,"blackList":"metrika,Non-Error promise rejection,partner-code-bundles,pcode,AdSDK,gtm.js,Invalid scheme,chrome-extension,anonymous,ntp is not defined,pubads,pagead,freed script,adfox,illegal character,Script error,Invalid scheme,Script error.,"},"advisory":{"url":"/a/ajax-advisory/","timeoutSeconds":5,"cookieName":"promo_advisory_new","cookieDeclineTimeout":86400,"cookieApplyTimeout":86400},"guideHints":{"url":"/ajax-get-guide-hints/","cookiePrefix":"gh_"},"demoPackage":{"cookieName":"demo_package"},"accountFill":{"url":"https://pay.kolesa.kz/cabinet?"},"urlToSettings":"/passport/settings/","gatewayScript":{"0":"https://pay.kolesa.kz/static/js/gateway/common/iframe-loader.js"},"paidServicesUrls":{"move-to-archive":"/my/ajax-move-to-archive/"},"messagesEndpoints":{"baseUrl":"https://chat.kolesa.kz/ms/chat","wsConnection":"wss://ws.kolesa.kz/v2/connection/websocket","getToken":"/v2/messages/getTokenForClient.json","getCredentials":"/v2/messages/getCredentialsForThreads.json","getThreads":"/v1/messages/getAllThreads.json","getThread":"/v1/messages/getThread.json","getMessage":"/v1/messages/getMessage.json","blockThread":"/v1/messages/blacklist/add.json","unblockThread":"/v1/messages/blacklist/remove.json","deleteThread":"/v1/messages/deleteThread.json","sendMessage":"/v1/messages/send.json","markAsRead":"/v1/messages/markAsRead.json","getChannelHash":"/v1/messages/getChannelHash.json","getThreadIdWithSupport":"/v1/messages/getThreadIdWithSupport.json"},"oaClient":"fis9f7ekamza4x12qtt7","convert":[],"priceHint":{"1":[{"to":5000},{"from":5000,"to":10000},{"from":10000,"to":15000}],"2":[{"to":"1 000 000","text":"до 1 млн"},{"from":"1 000 000","to":"2 000 000","text":"1 — 2 млн"},{"from":"2 000 000","to":"3 000 000","text":"2 — 3 млн"}],"3":[{"to":5000},{"from":5000,"to":10000},{"from":10000,"to":15000}],"4":[{"to":300000},{"from":300000,"to":600000},{"from":600000,"to":900000}]},"nps":{"project":"kolesa.kz","data":[],"url":"https://kolesa.kz/ms/nps/"},"userLogin":"kuzyrov@kolesa.kz","url-contents":"/get-contents/","route":"index:index","controller":"index","action":"index","app":"Frontend","userId":582896}'); json.priceHint[1][1].from;
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Object literal test
Json parse
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
The provided output is in JSON format, and we're interested in parsing the `priceHint` data. Looking at the provided output: ```json "json.priceHint[1][1].from" ``` It seems that the `priceHint` data is nested within an array. Specifically, it's located at index 1 of the second element (`[1]`) of the `priceHint` array (`[...]`). The value we're interested in is stored at index 1 of this sub-array (`[1]`).
Related benchmarks:
Object literal vs JSON.parse
JSON.parse vs fast-json-parse
JSON.parse vs object literal
JSON.parse vs string.splitds
Comments
Confirm delete:
Do you really want to delete benchmark?