-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can you create a very simple sketch that follows the filtering example described in the readme? #48
Comments
I posted to pastebin here. |
This is slightly different from the parsing example. The parsing example doesn't do any filtering from what I can tell. I want to use the filtering method to manipulate only the pieces of information I need from the tree rather than store the whole string response and then also store the whole tree before parsing. I thought that the filtering example in the read me was designed to reduce the memory load. I thought that the code for filtering, combined with the code for streaming would allow me to dump the information that I don't need rather than store it, saving me space. |
@I8P Yeah, I realized it as soon as I replied. That's why I removed my comment. Give me a couple of days, I will try it out and get back with a working example. |
does the above pastebin compile for you? Im getting the below error when I just do a straight copy paste from the bin sketch_aug22a.ino: In function 'char* parseJson(char*)': |
If I have the following response and store it for parsing: {
"sensor": {
"id": "418143",
"name": "analogpin0",
"type": "0",
"device_type": "Pressure Sensor",
"data_type_id": "35501",
"pager_type": "",
"display_name": "Analog Pin A0",
"use_data_storage": true,
"data_type": "json",
"data_structure": "{\"value\":\"Integer\"}"
}
} Shouldn't the following work? char** jsonFilter = (char*[]) {"sensor","id","display_name",NULL}; Explanation I found here: http://compsci.ca/v3/viewtopic.php?p=223745#223745 aJson.h only has the following functions though: parse(aJsonStream*)
parse(aJsonStream*, char**) // This one should be able to use a filter
parse(char*) According to the header file you will need a stream in order to use a filter. I haven't gotten a http client working with streams (yet) so I'm not able to test this. If this isn't correct, please let me know. I'm still learning about C and the Arduino ecosystem. |
@sjunnesson that is correct. I was not able to compile it. I am looking for help in determining why it doesn't work. Novice here. |
@epiccoolguy My JSON response is too large to store and then search. That is why I need to use streaming to look for the information as it is being streamed. When you say you haven't set up an http client to stream, do you mean that I something has to be done to a json stream before sending it to the arduino? Why use ajson if you use a computer in T&E first place? |
@I8P Not a json stream, aJsonStream is a class defined in this library. Have you looked at how the EthernetClient examples on the Arduino Playground work? You need to feed /* JSON stream that consumes data from a connection (usually
* Ethernet client) until the connection is closed. */
class aJsonClientStream : public aJsonStream {
public:
aJsonClientStream(Client *stream_)
: aJsonStream(NULL), client_obj(stream_)
{} Try passing this constructor the client you're using to receive the data and then pass that aJsonClientStream to I can't remember what I've tried myself. I gave up eventually on using additional libraries since they were also massive (example sketch size 90%) and instead used string.h functions to parse http responses. This library would've worked nice in combination with interactive-matter/HTTPClient, but both are kind of abandoned and HTTPClient is still using C-style streams while aJson has been updated for use with Arduino style streams. |
Thank you! ... It does seem like they are not in development. I am trying to see if I can parse the data using a Yun instead. More memory etc. I'll have to dig into Linux tools to do so I think. I8P
|
I am having exactly the same issue when initating the filter string for my program to process the JSON feed from Yahoo. initialize the filter: error from Arduino IDE (both 1.0.5 and 1.5.5) Really like to have an example to understand the filter usage. Thanks. |
@I8P did you end getting the filtering / stream running? as im working on something similar at the moment |
I don't see any evidence that the filter is used anywhere in the json parser code. |
I will be the first to admit that I am not a strong programmer in C/C++. I could really use an example sketch that uses the "Filtering while parsing" method described in the README.md file. It would help me through the following problem
I was getting an error while compiling that the "scalar object requires one element in initializer". To my understanding, the use of the char** is a pointer to a pointer but I honestly don't know what is needed to initialize this correctly:
char** jsonFilter = {"name,"format","height","width",NULL};
Also of note, there is a missing close quote after {"name in the README file.
The text was updated successfully, but these errors were encountered: