Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # json-stringify-safe
  2. Like JSON.stringify, but doesn't throw on circular references.
  3. ## Usage
  4. Takes the same arguments as `JSON.stringify`.
  5. ```javascript
  6. var stringify = require('json-stringify-safe');
  7. var circularObj = {};
  8. circularObj.circularRef = circularObj;
  9. circularObj.list = [ circularObj, circularObj ];
  10. console.log(stringify(circularObj, null, 2));
  11. ```
  12. Output:
  13. ```json
  14. {
  15. "circularRef": "[Circular]",
  16. "list": [
  17. "[Circular]",
  18. "[Circular]"
  19. ]
  20. }
  21. ```
  22. ## Details
  23. ```
  24. stringify(obj, serializer, indent, decycler)
  25. ```
  26. The first three arguments are the same as to JSON.stringify. The last
  27. is an argument that's only used when the object has been seen already.
  28. The default `decycler` function returns the string `'[Circular]'`.
  29. If, for example, you pass in `function(k,v){}` (return nothing) then it
  30. will prune cycles. If you pass in `function(k,v){ return {foo: 'bar'}}`,
  31. then cyclical objects will always be represented as `{"foo":"bar"}` in
  32. the result.
  33. ```
  34. stringify.getSerialize(serializer, decycler)
  35. ```
  36. Returns a serializer that can be used elsewhere. This is the actual
  37. function that's passed to JSON.stringify.
  38. **Note** that the function returned from `getSerialize` is stateful for now, so
  39. do **not** use it more than once.