A simple parser for JSON with Comments written in MATLAB
이 제출물을 팔로우합니다
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다
JSON+C parsing for MATLAB
This package offers some simple functions to handle JSON+C (JSON with comments) in a MATLAB script.
-
jsonc.removeJSONCommentsremoves JavaScript-style comments from the string (or char array) you give it as argument. -
jsonc.jsoncDecodeis a wrapper for MATLAB's nativejsondecode. It filters the string you give it thoughjsonc.removeJSONCommentsbefore passing it tojsondecode. -
jsonc.jsonEncodeis a wrapper for MATLAB's nativejsonencode. This tries to use thePrettyPrintoption if it is supported (which depends on your MATLAB version).
The demo.m script shows example usage.
>> demo
Original string:
{
// One-line comment
"foo": "bar", // One-line comment at end of line
/*
Multiline comment
*/
"singleLinerInString": "//",
"multilinerInString": "/*",
"*/": "baz"
}
String without comments:
{
"foo": "bar",
"singleLinerInString": "//",
"multilinerInString": "/*",
"*/": "baz"
}
recoveredData =
struct with fields:
foo: 'bar'
singleLinerInString: '//'
multilinerInString: '/*'
x__: 'baz'
Data re-encoded to JSON:
{
"foo": "bar",
"singleLinerInString": "//",
"multilinerInString": "/*",
"x__": "baz"
}
But why?
The JSON standard does not allow for comments. However, it is often convenient to allow for them when using JSON as a markup language for configuration files and the likes. Hence the need for the not-quite-official JSON+C variant.
Although there is already a similar implementation on the MATLAB file exchange, that relies on an external JSON parser and requires you to compile it with MEX for your target platform(s). This is a much more lightweight alternative implemented in "vanilla" MATLAB.
인용 양식
Sean Bone (2026). JSON+C parsing for MATLAB (https://github.com/seanbone/matlab-json-c/releases/tag/v1.1), GitHub. 검색 날짜: .
| 버전 | 퍼블리시됨 | 릴리스 정보 | Action |
|---|---|---|---|
| 1.1 | See release notes for this release on GitHub: https://github.com/SeanBone/matlab-json-c/releases/tag/v1.1 |
||
| 1.0 |
