Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
stream-stringify
Advanced tools
Create streams for nested JSON structures of which you don't know about on beforehand.
Cheaper than JSON.stringify
which always will buffers the entire object.
jsonString = ''
root = sstringify().on('data', (data) -> jsonString += data)
root.writeKeyValue "firstKey", "firstValue"
nestedObject = root.startNewObject "nestedObject"
innerArray = nestedObject.startNewArray "innerArray"
innerArray.writeElement 1
innerArray.writeElement [2,3]
innerArray.stop()
nestedObject.writeKeyValue "anotherInnerKey", "anotherInnerValue"
nestedObject.stop()
root.stop()
jsonString
is now:
{
"firstKey": firstValue,
"nestedObject": {
"innerArray": [
1,
[2,3]
],
"anotherInnerKey": anotherInnerValue
}
}
This stream supports functionality found in most streams, such as write()
, end()
, or destroy()
. The methods described below are specific for this stream.
Constructs the root of the JSON structure. When specified, the following options change the behaviour of the stream:
type
- String specifying the type of the stream root.
Object
(Default) An object with key-value pairsArray
An array with arbitrary contentprettyFormat
- Boolean specifying whether the object should be formatted beautifully.tabWidth
- If prettyFormat
is true
, then this is the number of spaces. Defaults to 2
.autoDestroy
- Boolean specifying whether the object should be destroyed when ended. Default is true
.Starts a new object stream which is connected to the specfied key
. Returns the stream. When using an array, do not specify key
.
Starts a new array stream which is connected to the specfied key
. Returns the stream. When using an array, do not specify key
.
Notifies the stream that there won't be more information. This will close the bracket. The stream will automatically be ended and destroyed when not used by other streams (unless autoDestroy=false
).
Writes a key and a value to the stream. Does not work when working with an array.
Writes an element to the stream. Does not work when working with an object.
npm install stream-stringify
FAQs
Stringify nested JSON through streams.
The npm package stream-stringify receives a total of 0 weekly downloads. As such, stream-stringify popularity was classified as not popular.
We found that stream-stringify demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.