× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Just please don't call the format for JSON because it's not - it is a JSON
look-alike
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 poor
performance.


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 (actually
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 like,
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 yours.

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 notation
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> wrote:

btw,

as a general rule you shoul NOT use object within objects unless you need
a array
of similar objects.

it just creates the need of a lot code you really don't need by keeping
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> wrote:

{
"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 you
need 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 you
can name the objects

"abc" : { ... }, // you still need the comma to separate the abc and
def element
"def" : { ... }

On Sun, Mar 12, 2017 at 11:37 PM, Jon Paris <jon.paris@xxxxxxxxxxxxxx

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 elements)
and 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:

The first part validated correctly and the second part validated

correctly

so I modified as follows and the complete string validated
correctly.

While this now validates if you have not pasted the entire string

that may

be why this change worked.

I don't know JSON but the repeating section I think needs to be

enclosed

in [ ] not { }

{
"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

bike. It

has a syntax error apparently but I'm danged if I can see what it is

-

admittedly I'm shaky on JSON so it is probably something obvious but

...

The array/collection/whatever that begins with as "workoutDate" is

the

part of the file that repeats. I've tried various minor corrections

on the

assumption that the error has to be trivial but without success.

{
"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)

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.



--
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.

--
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/>




--
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.





As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.