jswrap_json.h 1.6 KB

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * This file is part of Espruino, a JavaScript interpreter for Microcontrollers
  3. *
  4. * Copyright (C) 2013 Gordon Williams <gw@pur3.co.uk>
  5. *
  6. * This Source Code Form is subject to the terms of the Mozilla Public
  7. * License, v. 2.0. If a copy of the MPL was not distributed with this
  8. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  9. *
  10. * ----------------------------------------------------------------------------
  11. * JavaScript JSON-handling Functions
  12. * ----------------------------------------------------------------------------
  13. */
  14. #include "jsvar.h"
  15. JsVar *jswrap_json_stringify(JsVar *v);
  16. JsVar *jswrap_json_parse(JsVar *v);
  17. typedef void (*JsfGetJSONCallbackString)(void *data, const char *string);
  18. typedef void (*JsfGetJSONCallbackVar)(void *data, JsVar *var);
  19. /* This is like jsfGetJSONWithCallback, but handles ONLY functions (and does not print the initial 'function' text) */
  20. void jsfGetJSONForFunctionWithCallback(JsVar *var, JsfGetJSONCallbackString callbackString, JsfGetJSONCallbackVar callbackVar, void *callbackData);
  21. /* Dump to JSON, using the given callbacks for printing data */
  22. void jsfGetJSONWithCallback(JsVar *var, JsfGetJSONCallbackString callbackString, JsfGetJSONCallbackVar callbackVar, void *callbackData);
  23. /* Convenience function for using jsfGetJSONWithCallback - print to var */
  24. void jsfGetJSON(JsVar *var, JsVar *result);
  25. /* Convenience function for using jsfGetJSONWithCallback - print to console */
  26. void jsfPrintJSON(JsVar *var);
  27. /* Convenience function for using jsfGetJSONForFunctionWithCallback - print to console */
  28. void jsfPrintJSONForFunction(JsVar *var);