|
But Scott has understood the problem Henrik. This was not some arbitrary
syntax that I made up. It is the output from a real live Schwinn exercise
machine. I wanted to do some low level processing on it and to my
untrained eye it looked like json.
I appreciate your lessons on how it should perhaps have been designed but
sadly that is of no use to me in processing it.
Jon Paris
www.partner400.com
www.SystemiDeveloper.com
On Mar 13, 2017, at 4:34 AM, Henrik Rützou <hr@xxxxxxxxxxxx> wrote:JSON
Just please don't call the format for JSON because it's not - it is a
look-alikepoor
homebrewed messy format that may or may not be processed by a homebrewed
JSON parser with a lot of work-around code that in best case will cause
performance.(actually
On Mon, Mar 13, 2017 at 4:04 AM, Scott <scottgcampbell@xxxxxxxxx> wrote:
Jon,
That's funny, I thought I recognized the data when I saw it, I have a
Schwinn 170 that I pulled the data off of and had the same issue
like,emailed them to ask when they would fix it at the time), I ended up just
parsing it myself line by line and storing the workouts converting them
from JSON to arrays after. I can email you the code off list if you
yours.I haven't looked at it in more than 2 years, I'm sure it has corroded in
that time :)
I used raphael.js and justguage.js to display some charts and graphs of
the workouts.
Your file looks just a tiny bit different than mine, I had made some
assumptions about where open and close brackets were when processing the
file to find user info and workouts, but would need to be changed for
notation
Scott
On 3/12/2017 5:42 PM, Henrik Rützou wrote:
Example:
let say you have a number of users and you what to process them the
typical
mainloop to process the DOM since JSON isn't a object but only a
wrote:of
a DOM object:
myObj = JSON.parse(allUsers)
for (i = 0; i < myObj.length; i++) {
myRow = myObj(i)
Fields can now be processed like
myRow.userName
myRow.userAge
but when you reach workOutDate that ends jo you need to retreive the
object
myWorkOutDate = myRow.workOutDate
and proces the folowing fields like
myWorkOutDate.Month
myWorkOutDate.Day
myWorkOutDate.Year
This is what is called copy by reference since both myRow and
MyWorkOutDate
only exists as a storage reference to the original myObj but often you
want
to make
either a shallow copy or a deep copy that dosn't refer to the original.
The
deep copy
is actually hard to make since it contains the DOM properties from the
original.
The shallow copy is easier to make by using JSON as the intermediate
format:
myWorkOutDate = JSON.stringify(myRow.myWorkOutDate)
myWorkOutDate = JSON.parse(myWorkOutDate)
On Mon, Mar 13, 2017 at 12:13 AM, Henrik Rützou <hr@xxxxxxxxxxxx>
need
btw,
as a general rule you shoul NOT use object within objects unless you
keepinga array
of similar objects.
it just creates the need of a lot code you really don't need by
wrote:the elements
in one level and there is no Xpath i JSON.
On Sun, Mar 12, 2017 at 11:52 PM, Henrik Rützou <hr@xxxxxxxxxxxx>
you
{
"userName": "BERT ",
"userAge": 28,
"userWeight": 180,
"userGender": "M",
"userHeight": "72",
"mID": "GB"
"workoutDate": {
"Month": 2,
"Day": 22,
"Year": 2016
},
"distance": 10.1,
"finishTime": {
"Hours": 13,
"Minutes": 38
},
"pctAverageHeartRateInZone": 0.0,
"averageSpeed": 15.1,
"totalWorkoutTime": {
"Hours": 0,
"Minutes": 40
},
"averageWattsPerHour": 75.0,
"totalCalories": 211.0,
"avgHeartRate": 129.3,
"avgRpm": 62,
"avgLevel": 4
}
or if you have x workoutdates
{
"userName": "BERT ",
"userAge": 28,
"userWeight": 180,
"userGender": "M",
"userHeight": "72",
"mID": "GB"
"workoutDates" [
{ "workoutDate": {
"Month": 2,
"Day": 22,
"Year": 2016
},
"distance": 10.1,
"finishTime": {
"Hours": 13,
"Minutes": 38
},
"pctAverageHeartRateInZone": 0.0,
"averageSpeed": 15.1,
"totalWorkoutTime": {
"Hours": 0,
"Minutes": 40
},
"averageWattsPerHour": 75.0,
"totalCalories": 211.0,
"avgHeartRate": 129.3,
"avgRpm": 62,
"avgLevel": 4
},{ "workoutDate" :
.....
}
]
}
On Sun, Mar 12, 2017 at 11:42 PM, Henrik Rützou <hr@xxxxxxxxxxxx>
wrote:
Or you may pot the object into an array [{ ... },{ ....}] // still
youneed the comma to separate the
array elements
On Sun, Mar 12, 2017 at 11:41 PM, Henrik Rützou <hr@xxxxxxxxxxxx>
wrote:
Jon,
you can't have a object and a object }{ - that is forbidden, but
andcan name the objects
"abc" : { ... }, // you still need the comma to separate the abc
jon.paris@xxxxxxxxxxxxxxdef element
"def" : { ... }
On Sun, Mar 12, 2017 at 11:37 PM, Jon Paris <
elements)wrote:
Thanks Don - I tried a similar approach and also tried adding the [
for an array to get the repeats - but still can't make it work.
I also tried coding some XML (where I understand repeating
it isand using an on-line convertor to convert it to json - sadly it
doesn't
help because it converts it to a series of arrays which is not how
the
original data is presented.
Jon Paris
www.partner400.com
www.SystemiDeveloper.com
On Mar 12, 2017, at 6:00 PM, Don Brown <DBrown@xxxxxxxxxx> wrote:
correctly
The first part validated correctly and the second part validated
so I modified as follows and the complete string validatedthat may
correctly.
While this now validates if you have not pasted the entire string
be why this change worked.enclosed
I don't know JSON but the repeating section I think needs to be
in [ ] not { }bike. It
{
"userName": "BERT ",
"userAge": 28,
"userWeight": 180,
"userGender": "M",
"userHeight": "72",
"mID": "GB",
"workoutDate": {
"Month": 2,
"Day": 22,
"Year": 2016
},
"distance": 10.1,
"finishTime": {
"Hours": 13,
"Minutes": 38
},
"pctAverageHeartRateInZone": 0.0,
"averageSpeed": 15.1,
"totalWorkoutTime": {
"Hours": 0,
"Minutes": 40
},
"averageWattsPerHour": 75.0,
"totalCalories": 211.0,
"avgHeartRate": 129.3,
"avgRpm": 62,
"avgLevel": 4
}
Don Brown
From: Jon Paris <jon.paris@xxxxxxxxxxxxxx>
To: "Web400@Midrange. Com" <web400@xxxxxxxxxxxx>
Date: 13/03/2017 07:03 AM
Subject: [WEB400] JSON Syntax error
Sent by: "WEB400" <web400-bounces@xxxxxxxxxxxx>
The JSON below is an extract from a file produced by an exercise
has a syntax error apparently but I'm danged if I can see what
but-
admittedly I'm shaky on JSON so it is probably something obvious
is...
The array/collection/whatever that begins with as "workoutDate"
correctionsthe
part of the file that repeats. I've tried various minor
list----------on the
assumption that the error has to be trivial but without success.mailing
{
"userName": "BERT ",
"userAge": 28,
"userWeight": 180,
"userGender": "M",
"userHeight": "72",
"mID": "GB"
} {
"workoutDate": {
"Month": 2,
"Day": 22,
"Year": 2016
},
"distance": 10.1,
"finishTime": {
"Hours": 13,
"Minutes": 38
},
"pctAverageHeartRateInZone": 0.0,
"averageSpeed": 15.1,
"totalWorkoutTime": {
"Hours": 0,
"Minutes": 40
},
"averageWattsPerHour": 75.0,
"totalCalories": 211.0,
"avgHeartRate": 129.3,
"avgRpm": 62,
"avgLevel": 4
}
Can somebody spot what the problem is here.
Jon Paris
www.partner400.com
www.SystemiDeveloper.com
--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400)
listmailing list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/web400.
--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400)
To post a message email: WEB400@xxxxxxxxxxxxThis is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400)
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/web400.
--
mailing list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/web400.
Regards,
Henrik Rützou
http://powerEXT.com <http://powerext.com/>
Regards,
Henrik Rützou
http://powerEXT.com <http://powerext.com/>
Regards,
Henrik Rützou
http://powerEXT.com <http://powerext.com/>
Regards,
Henrik Rützou
http://powerEXT.com <http://powerext.com/>
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing
list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/web400.
--
Regards,
Henrik Rützou
http://powerEXT.com <http://powerext.com/>
--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/web400.
--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing
list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/web400.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.