1
$\begingroup$

UPDATE: 25-Jan-17 12:02AM CET

FirebaseLink package does not work on windows

UPDATE: 25-Jan-17 12:02AM CET

The problem could probably be reduced to: "How do I get the literal string

"{\" foo3 \":\" bar3 \"}"

from the association

<|"foo3" -> "bar3"|>

?"

This makes the problem testable, I suppose.

ORIGINAL QUESTION

I am working on a notebook where I have to execute external Windows10 commands ( i.e. write data to a Firebase database using curl ). In question How to call external commands with parameters on Win7? I found that I should use

Run[command].

At the DOS level I want to execute a string in this format:

curl -X PUT -d "{\"name\":{\"last\": \"sparrow\"}}" https://samplechat.firebaseio-demo.com/users/jack.json

( See also question: Firebase - How to write using curl? )

The string

"{\"name\":{\"last\": \"sparrow\"}}"

must be in JSON format recognizable by Firebase. In my application this data comes from a function which returns a list of associations.

ExportString[getBkmkCompEvntMrkt[], "JSON"]

So I have

curl -X PUT -d
ExportString[getBkmkCompEvntMrkt[], "JSON"], and
https:myfirebasedb/target.json

to work with.

Sofar I have consistently failed to get this working.

Please advise.

$\endgroup$
2
  • 1
    $\begingroup$ ExportString[<|"foo3" -> "bar3"|>, "RawJSON", "Compact" -> True]? $\endgroup$
    – Kuba
    Commented Jan 25, 2017 at 11:16
  • $\begingroup$ Wow...! Thank you so much. This gives me something to work with. $\endgroup$ Commented Jan 25, 2017 at 11:19

2 Answers 2

1
$\begingroup$

For your updated question this might work:

KeyValueMap[Colon, <|"foo3" -> "bar3"|>]
ToString[%, InputForm]
StringReplace[%, "\[Colon]" -> ":"]
{"foo3" \[Colon] "bar3"}

"{\"foo3\" \[Colon] \"bar3\"}"

"{\"foo3\" : \"bar3\"}"
$\endgroup$
2
  • $\begingroup$ Thanks. This question got a bit out of hand, really ( also mathematica.stackexchange.com/questions/136166/… ). - The point is that I had problems with the FirebaseLink package which is a Mac only hack. While modifying the package I came across some of the issues above. - It is all running now. $\endgroup$ Commented Jan 26, 2017 at 18:00
  • $\begingroup$ The FirebaseLink package is not from Wolfram, it lives on Github. $\endgroup$ Commented Jan 26, 2017 at 18:01
0
$\begingroup$

The question arose from using the package FirebaseLink. It turned out that this package does not work on Windows(!). I solved the issue here: Patch for FirebaseLink if you want to use the package in a windows environment.

Windows requires Run for external programs and does not allow single quotes around the firebase URL.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.