Compiling with aJSON

I am trying to simply compile a sketch using the aJSON library.
I think I am following the examples correctly but I keep on getting a compile time error.
Any help greatly appreciated.

My code looks like (I appear to get an error on the first call to aJson.getObjectItem():

#include "aJSON.h"

unsigned long last_print = 0;
aJsonStream serial_stream(&Serial);
int ledPin = 52;
int sensorPin = A8;
int sensorValue = 0;
int refreshRate = 0;
int ARDUINO_RANGE = 4096;
int PARKER_RANGE = 250;
long pressureTotal = 0;
bool laseron = false;
bool initialized = false;

void setup()
{
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin,LOW);
}

void processSysMessage(aJsonObject *msg)
{
aJsonObject foundsysmsg = aJson.getObjectItem(msg, "sys");
/
if(foundsysmsg)
{
aJsonObject *msg = aJson.createObject();
aJson.addItemToObject(msg,"ARDUINOMAIN",NULL);
aJson.print(msg, &serial_stream);
Serial.println();
aJson.deleteItem(msg);
}
*/
}

void processMessage(aJsonObject *msg)
{
aJsonObject *foundlasermsg = aJson.getObjectItem(msg, "LASER");
if (foundlasermsg)
{
if(laseron)
{
digitalWrite(ledPin,LOW);
laseron = false;
}
else
{
digitalWrite(ledPin,HIGH);
laseron = true;
}
}
}

void loop()
{
refreshRate += 1;

if (serial_stream.available()) {
/* First, skip any accidental whitespace like newlines. */
serial_stream.skip();
}

if (serial_stream.available()) {
/* Something real on input, let's take a look. */
aJsonObject *msg = aJson.parse(&serial_stream);

if(!initialized)
{
processSysMessage(msg);
}
else
processMessage(msg);

aJson.deleteItem(msg);
}

if(initialized)
{
sensorValue = analogRead(sensorPin);
pressureTotal += sensorValue;
if(millis() - last_print > 1000)
{
aJsonObject *msg = aJson.createObject();
aJson.addItemToObject(msg,"PRESSURE",aJson.createItem(((((double)pressureTotal)/1000)/ARDUINO_RANGE)PARKER_RANGE));
aJson.print(msg, &serial_stream);
Serial.println(); /
Add newline. */
aJson.deleteItem(msg);
last_print = millis();
pressureTotal = 0;
}
}
}

When I compile, I get the following errors:

C:\Users\ADMINI~1\AppData\Local\Temp\build4457076699357761172.tmp\ArduinoMain.cpp.o C:\Users\ADMINI~1\AppData\Local\Temp\build4457076699357761172.tmp/core.a -LC:\Users\ADMINI~1\AppData\Local\Temp\build4457076699357761172.tmp -lm
C:\Users\ADMINI~1\AppData\Local\Temp\build4457076699357761172.tmp\ArduinoMain.cpp.o: In function processSysMessage(aJsonObject*)': C:\Program Files (x86)\Arduino/ArduinoMain.ino:25: undefined reference to aJson'
C:\Program Files (x86)\Arduino/ArduinoMain.ino:25: undefined reference to aJson' C:\Program Files (x86)\Arduino/ArduinoMain.ino:25: undefined reference to aJsonClass::getObjectItem(aJsonObject*, char const*)'
C:\Users\ADMINI~1\AppData\Local\Temp\build4457076699357761172.tmp\ArduinoMain.cpp.o: In function processMessage(aJsonObject*)': C:\Program Files (x86)\Arduino/ArduinoMain.ino:39: undefined reference to aJson'
C:\Program Files (x86)\Arduino/ArduinoMain.ino:39: undefined reference to aJson' C:\Program Files (x86)\Arduino/ArduinoMain.ino:39: undefined reference to aJsonClass::getObjectItem(aJsonObject*, char const*)'
C:\Users\ADMINI~1\AppData\Local\Temp\build4457076699357761172.tmp\ArduinoMain.cpp.o: In function loop': C:\Program Files (x86)\Arduino/ArduinoMain.ino:59: undefined reference to aJsonStream::available()'
C:\Program Files (x86)\Arduino/ArduinoMain.ino:61: undefined reference to aJsonStream::skip()' C:\Program Files (x86)\Arduino/ArduinoMain.ino:64: undefined reference to aJsonStream::available()'
C:\Program Files (x86)\Arduino/ArduinoMain.ino:66: undefined reference to aJson' C:\Program Files (x86)\Arduino/ArduinoMain.ino:66: undefined reference to aJson'
C:\Program Files (x86)\Arduino/ArduinoMain.ino:66: undefined reference to aJsonClass::parse(aJsonStream*)' C:\Program Files (x86)\Arduino/ArduinoMain.ino:73: undefined reference to aJson'
C:\Program Files (x86)\Arduino/ArduinoMain.ino:75: undefined reference to aJson' C:\Program Files (x86)\Arduino/ArduinoMain.ino:75: undefined reference to aJsonClass::deleteItem(aJsonObject*)'
C:\Program Files (x86)\Arduino/ArduinoMain.ino:82: undefined reference to aJson' C:\Program Files (x86)\Arduino/ArduinoMain.ino:82: undefined reference to aJson'
C:\Program Files (x86)\Arduino/ArduinoMain.ino:82: undefined reference to aJsonClass::createObject()' C:\Program Files (x86)\Arduino/ArduinoMain.ino:85: undefined reference to aJson'
C:\Program Files (x86)\Arduino/ArduinoMain.ino:85: undefined reference to aJson' C:\Program Files (x86)\Arduino/ArduinoMain.ino:85: undefined reference to aJsonClass::createItem(double)'
C:\Program Files (x86)\Arduino/ArduinoMain.ino:85: undefined reference to aJson' C:\Program Files (x86)\Arduino/ArduinoMain.ino:85: undefined reference to aJson'
C:\Program Files (x86)\Arduino/ArduinoMain.ino:85: undefined reference to aJsonClass::addItemToObject(aJsonObject*, char const*, aJsonObject*)' C:\Program Files (x86)\Arduino/ArduinoMain.ino:85: undefined reference to aJson'
C:\Program Files (x86)\Arduino/ArduinoMain.ino:85: undefined reference to aJson' C:\Program Files (x86)\Arduino/ArduinoMain.ino:85: undefined reference to aJsonClass::print(aJsonObject*, aJsonStream*)'
C:\Program Files (x86)\Arduino/ArduinoMain.ino:86: undefined reference to aJson' C:\Program Files (x86)\Arduino/ArduinoMain.ino:86: undefined reference to aJson'
C:\Program Files (x86)\Arduino/ArduinoMain.ino:86: undefined reference to aJsonClass::deleteItem(aJsonObject*)' C:\Users\ADMINI~1\AppData\Local\Temp\build4457076699357761172.tmp\ArduinoMain.cpp.o: In function Print':
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:43: undefined reference to vtable for aJsonStream' C:\Users\ADMINI~1\AppData\Local\Temp\build4457076699357761172.tmp\ArduinoMain.cpp.o: In function aJsonStream':
C:\Users\ADMINI~1\AppData\Local\Temp\build4457076699357761172.tmp/aJSON.h:75: undefined reference to `vtable for aJsonStream'
collect2.exe: error: ld returned 1 exit status
Error compiling.

C:\Program Files (x86)\Arduino/ArduinoMain.ino:25: undefined reference to `aJson'

Isn't it obvious? Your code does not create an object called aJson. If you think the library does (or even if you don't), you should post a link to the library.

I do not think that is right.

Here is a link to the aJSON library (an Arduino JSON parser):

All the example implementations are formed exactly as I have.
They use aJSON as a class name so it does not have to be defined beforehand.
Essentially, you are just calling the function when you use aJSON by itself.

Alternatively, is there another JSON encoder/decoder that people recommend?

When I downloaded the aJson library, and installed it properly, I got one error when compiling your code:

Binary sketch size: 12,386 bytes (of a 258,048 byte maximum)

I did that using 1.0.5.

Please read the two posts by Nick Gammon at the top of this Forum for guidelines on posting source code and using code tags. Those guidelines will help you get more responses to your posts.

pistorinoj:
#include "aJSON.h"
...
Error compiling.

Why do you try to include the library name included in double quotes?

The examples included in the library include the name in angle brackets:

#include <aJSON.h>

The difference between double quotes and angle brackets makes a difference about the directory path where the compiler is looking for the library files.

@jurs: It still should find the library if they are installed correctly. The quotes simply says to search the current working directly first. If that fails, it will eventually search the same default ("< >") directory. I think he has the library set up wrong.

I have done it with both <> and "". Double quotes works because the function definitions are working. That is, if I comment out the offending line, I can compile with the function definition referring to aJson types.

Yeah, this was a library loading issue.
I reloaded the library and it worked.
Not sure why the function definition still worked even with the library not loading correctly.