@ HH  OK, understood

OK Progress. 

@Richard: OK got it.. Yes, I was reinserting an array where I should have just 
been putting a string into the tStack and tCard
@Phil: Right… removing quotes was necessary.

This works:

put "SivaSiva" into tStack # this is a key just insert the string - not the 
array
put "0" into tGroupCounter

   repeat for each line x in tData
      put item 1 of x into tCard # this is a key just insert the string - not 
the array
      if tCard <> tPreviousCard then put 0 into tGroupCounter
      put item 2 of x into tGroupType
      if tGroup = "link" then
         add 1 to tGroupCounter
         put (tGroupType & tGroupCounter) into tGroupType
      end if
      put tGroupType into aPortalLinks[tStack][tCard][tGroup]
      put item 3 of x into aPortalLinks[tStack][tCard][tGroupType][tLabel]
      put item 4 of x into aPortalLinks[tStack][tCard][tGroupType][tImgPath]
      put item 5 of x into aPortalLinks[tStack][tCard][tGroupType][tMessage]
      put item 6 of x into aPortalLinks[tStack][tCard][tGroupType][tTarget]
      put item 7 of x into aPortalLinks[tStack][tCard][tGroupType][tOrientation]
     put tCard into tPreviousCard
   end repeat
   put JsonExport(aPortalLinks)

Yes! Now we get:

{
        "SivaSiva": {
                "surprise-portal": {
                        "link7": {
                                "tLabel": "Bodhinatha's\\nDarshan",
                                "tTarget": 
"http://www.himalayanacademy.com/sivasiva-api/random-bodhinatha";,
                                "tImgPath": 
"img/portal-link-thumbs/surprise-portal/bodhinatha_thm.jpg",
                                "tMessage": "displayImage",
                                "tOrientation": "portrait"
                        },
                        "link9": {
                                "tLabel": "Five Inspired Quotes",
                                "tTarget": 
"http://www.himalayanacademy.com/sivasiva-api/random-trilogy";,
                                "tImgPath": 
"img/portal-link-thumbs/surprise-portal/trilogy-quotes_thm.jpg",
                                "tMessage": "fetchTextReader",
                                "tOrientation": "portrait"
                        },
                        "link8": {
                                "tLabel": "Video\\nWorld",
                                "tTarget": 
"http://www.himalayanacademy.com/sivasiva-api/random-video";,
                                "tImgPath": 
"img/portal-link-thumbs/surprise-portal/video_thm.jpg",
                                "tMessage": "playVideo",
                                "tOrientation": "landscape"
                        },
                        "link1": {
                                "tLabel": "Verses from\\nthe Vedas",
                                "tTarget": 
"http://www.himalayanacademy.com/sivasiva-api/random-vedas";,
                                "tImgPath": 
"img/portal-link-thumbs/surprise-portal/vedas-verses_thm.jpg",
                                "tMessage": "fetchTextReader",
                                "tOrientation": "portrait"
                        },
                        "link2": {
                                "tLabel": "Tirukural\\nCouplets",
                                "tTarget": 
"http://www.himalayanacademy.com/sivasiva-api/random-kural";,
                                "tImgPath": 
"img/portal-link-thumbs/surprise-portal/tirukural-verses_thm.jpg",
                                "tMessage": "fetchTextReader",
                                "tOrientation": "portrait"
                        },
                        "link3": {
                                "tLabel": "Inspired\\nAudio Talks",
                                "tTarget": 
"http://www.himalayanacademy.com/sivasiva-api/random-talk";,
                                "tImgPath": 
"img/portal-link-thumbs/surprise-portal/talks_thm.jpg",
                                "tMessage": "playAudio",
                                "tOrientation": "portrait"
                        },
                        "link4": {
                                "tLabel": "Songs\\nAnd Chants",
                                "tTarget": 
"http://www.himalayanacademy.com/sivasiva-api/random-some";,
                                "tImgPath": 
"img/portal-link-thumbs/surprise-portal/songs_thm.jpg",
                                "tMessage": "playAudio",
                                "tOrientation": "portrait"
                        },
                        "hero-image": {
                                "tLabel": "Surprise Me",
                                "tTarget": "",
                                "tImgPath": 
"img/portal-heros/surprise-hero.jpg",
                                "tMessage": "",
                                "tOrientation": ""
                        },
                        "link5": {
                                "tLabel": "Sacred\\nArt",
                                "tTarget": 
"http://www.himalayanacademy.com/sivasiva-api/random-art";,
                                "tImgPath": 
"img/portal-link-thumbs/surprise-portal/art_thm.jpg",
                                "tMessage": "displayImage",
                                "tOrientation": "portrait"
                        },
                        "link6": {
                                "tLabel": "Gurudeva's\\nDarshan",
                                "tTarget": 
"http://www.himalayanacademy.com/sivasiva-api/random-gurudeva";,
                                "tImgPath": 
"img/portal-link-thumbs/surprise-portal/gurudeva_thm.jpg",
                                "tMessage": "displayImage",
                                "tOrientation": "portrait"
                        }
                },
                "read-portal": {
                        "link7": {
                                "tLabel": "Educational\\nInsights",
                                "tTarget": 
"http://www.himalayanacademy.com/site/search/file_id/_ei";,
                                "tImgPath": 
"img/portal-link-thumbs/surprise-portal/edu-insights_thm.jpg",
                                "tMessage": "browseWeb",
                                "tOrientation": "portrait"
                        },
                        "link8": {
                                "tLabel": "Hindu\\nTimeline",
                                "tTarget": " 
http://www.himalayanacademy.com/book/dancing-with-siva/527";,
                                "tImgPath": 
"img/portal-link-thumbs/surprise-portal/timeline_thm.jpg",
                                "tMessage": "browseWeb",
                                "tOrientation": "portrait"
                        },
                        "link1": {
                                "tLabel": "Frequently\\nAsked\\nQuestions",
                                "tTarget": "faq-module",
                                "tImgPath": 
"img/portal-link-thumbs/surprise-portal/faq_thm.jpg",
                                "tMessage": "goModuleStack",
                                "tOrientation": "portrait"
                        },
                        "link2": {
                                "tLabel": "Gurudeva's\\nSpiritual\\nToolbox",
                                "tTarget": "gr-toolbox-module",
                                "tImgPath": 
"img/portal-link-thumbs/surprise-portal/gr-toolbox_thm.jpg",
                                "tMessage": "goModuleStack",
                                "tOrientation": "portrait"
                        },
                        "link3": {
                                "tLabel": "All Our\\nOn-Line\\nBooks",
                                "tTarget": 
"http://www.himalayanacademy.com/readlearn/books";,
                                "tImgPath": 
"img/portal-link-thumbs/surprise-portal/publications_thm.jpg",
                                "tMessage": "browseWeb",
                                "tOrientation": "landscape"
                        },
                        "link4": {
                                "tLabel": "Lesson of\\nthe Day",
                                "tTarget": 
"http://www.himalayanacademy.com/livespiritually/become-student/todays-lesson";,
                                "tImgPath": 
"img/portal-link-thumbs/surprise-portal/daily-lesson_thm.jpg",
                                "tMessage": "browseWeb",
                                "tOrientation": "portrait"
                        },
                        "hero-image": {
                                "tLabel": "Read, Learn, Study",
                                "tTarget": "",
                                "tImgPath": "img/portal-heros/read-hero.jpg",
                                "tMessage": "",
                                "tOrientation": ""
                        },
                        "link5": {
                                "tLabel": "Path to Siva:\\nA Catechism\\nfor 
Youth",
                                "tTarget": "path-to-siva-module",
                                "tImgPath": 
"img/portal-link-thumbs/surprise-portal/path-to-siva_thm.jpg",
                                "tMessage": "goModuleStack",
                                "tOrientation": "portrait"
                        },
                        "link6": {
                                "tLabel": "A Character\\nBuilding\\nWorkbook",
                                "tTarget": "character-building-module",
                                "tImgPath": 
"img/portal-link-thumbs/surprise-portal/character-building_thm.jpg",
                                "tMessage": "goModuleStack",
                                "tOrientation": "portrait"
                        }
                },
                "home": {
                        "link7": {
                                "tLabel": "Our\\nWebsite",
                                "tTarget": "website-portal",
                                "tImgPath": 
"img/portal-link-thumbs/home/home-website_thm.jpg",
                                "tMessage": "goPortalCard",
                                "tOrientation": "portrait"
                        },
                        "link8": {
                                "tLabel": "Fun \\n Games",
                                "tTarget": "fun-portal",
                                "tImgPath": 
"img/portal-link-thumbs/home/home-fun_thm.jpg",
                                "tMessage": "goPortalCard",
                                "tOrientation": "portrait"
                        },
                        "link1": {
                                "tLabel": "Gems of\\nWisdom",
                                "tTarget": "gems-module",
                                "tImgPath": 
"img/portal-link-thumbs/home/home-gems_thm.jpg",
                                "tMessage": "goModuleStack",
                                "tOrientation": "portrait"
                        },
                        "link2": {
                                "tLabel": "Surprise\\nMe",
                                "tTarget": "surprise-portal",
                                "tImgPath": 
"img/portal-link-thumbs/home/home-surprise_thm.jpg",
                                "tMessage": "goPortalCard",
                                "tOrientation": "portrait"
                        },
                        "link3": {
                                "tLabel": "Look",
                                "tTarget": "look-portal",
                                "tImgPath": 
"img/portal-link-thumbs/home/home-look_thm.jpg",
                                "tMessage": "goPortalCard",
                                "tOrientation": "portrait"
                        },
                        "link4": {
                                "tLabel": "Listen",
                                "tTarget": "listen-portal",
                                "tImgPath": 
"img/portal-link-thumbs/home/home-listen_thm.jpg",
                                "tMessage": "goPortalCard",
                                "tOrientation": "portrait"
                        },
                        "hero-image": {
                                "tLabel": "Portals to Saivite Hinduism",
                                "tTarget": "",
                                "tImgPath": "img/portal-heros/home-hero.jpg",
                                "tMessage": "",
                                "tOrientation": ""
                        },
                        "link5": {
                                "tLabel": "Read",
                                "tTarget": "read-portal",
                                "tImgPath": 
"img/portal-link-thumbs/home/home-read_thm.jpg",
                                "tMessage": "goPortalCard",
                                "tOrientation": "portrait"
                        },
                        "link6": {
                                "tLabel": "Practice",
                                "tTarget": "practice-portal",
                                "tImgPath": 
"img/portal-link-thumbs/home/home-practice_thm.jpg",
                                "tMessage": "goPortalCard",
                                "tOrientation": "portrait"
                        }
                }
        }
}


This is close to what we need.

I just wish there were ways to maintain input order —> output order, without 
having to resort to  “hacky" sort keys functions   and iterating again through 
all the data, or being forced to add a sort key to the input data...just to get 
back to order of that the data was in on input. That order may not be 
alphanumeric… but a custom order. 

Example: fruits from sweetest to less sweet: 

Input order:

Dates
Figs
Pineapple
Oranges
Papaya
Apples

So how to maintain that same input order —> output into the resulting JSON? 
tricky. Will start playing with that, but if you have ideas let me know.

And I still have that niggling CR to pass in (from tab delimited raw text) and 
out (to Json) correctly  “\n” —> “\\n”  

Thanks for helping… I’m almost flying now… 

BR









On 4/18/16, 2:46 PM, "use-livecode on behalf of Phil Davis" 
<use-livecode-boun...@lists.runrev.com on behalf of rev...@pdslabs.net> wrote:

>Are tCard, tStack tGroup etc meant to be containers? If so, you don't 
>want them in quotes. That will make them each act as a literal value, 
>not as a container of a value.
>
>I love low-hanging fruit.  :-)
>
>Phil Davis
_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to