JsonArray.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Arduino JSON library
  3. * Benoit Blanchon 2014 - MIT License
  4. */
  5. #pragma once
  6. #include "JsonValue.h"
  7. #include "JsonArrayIterator.h"
  8. namespace ArduinoJson
  9. {
  10. namespace Parser
  11. {
  12. class JsonObject;
  13. class JsonArray : JsonValue
  14. {
  15. public:
  16. JsonArray()
  17. {
  18. }
  19. JsonArray(JsonValue value)
  20. : JsonValue(value)
  21. {
  22. }
  23. bool success()
  24. {
  25. return isArray();
  26. }
  27. JsonValue operator[](int index)
  28. {
  29. return JsonValue::operator[](index);
  30. }
  31. int size()
  32. {
  33. return isArray() ? childrenCount() : 0;
  34. }
  35. JsonArrayIterator begin()
  36. {
  37. return isArray() ? firstChild() : null();
  38. }
  39. JsonArrayIterator end()
  40. {
  41. return isArray() ? nextSibling() : null();
  42. }
  43. DEPRECATED int getLength()
  44. {
  45. return size();
  46. }
  47. DEPRECATED JsonArray getArray(int index)
  48. {
  49. return operator[](index);
  50. }
  51. DEPRECATED bool getBool(int index)
  52. {
  53. return operator[](index);
  54. }
  55. DEPRECATED double getDouble(int index)
  56. {
  57. return operator[](index);
  58. }
  59. DEPRECATED JsonObject getHashTable(int index);
  60. DEPRECATED long getLong(int index)
  61. {
  62. return operator[](index);
  63. }
  64. DEPRECATED char* getString(int index)
  65. {
  66. return operator[](index);
  67. }
  68. };
  69. }
  70. }