JSON error and Run script error - html

Apologies for any incorrect formatting I am new to these message boards
I am using HTML to customise a Textbox in Spotfire and although I get no errors in the Spotfire client I get the following error when I open the Spotfire analysis in Chrome
{ "titleFontColor":"#999999", "value":<SpotfireControl id="98bb1934a3c14ca2ab598deb672b8e44" />, "valueFontColor":"#010101", "symbol":"%", "min":<SpotfireControl id="0a05e2f1c4094273870d97a23b69efe2" />, "max":<SpotfireControl id="033f79eeccdb46ef982262c3c8a4ed0e" />, "humanFriendly":false, "humanFriendlyDecimal":2, "gaugeWidthScale":2.5, "gaugeColor":"#ebebeb", "label":"", "labelFontColor":"#b3b3b3", "shadowOpacity":0.2, "shadowSize":5, "shadowVerticalOffset":3, "levelColors":["#a9d70b","#f9c802","#ff0000"], "startAnimationTime":100, "startAnimationType":">", "donutStartAngle":90, "hideValue":true, "hideMinMax":true, "hideInnerShadow":false, "noGradient":false, "donut":true, "counter":false, "decimals":0, "formatNumber":false,
"customSectors": [{
"color" : "#D8181C",
"lo" : 0,
"hi" : 1
},{
"color" : "#F5CC0A",
"lo" : 1,
"hi" : 2
},{
"color" : "#50AF28",
"lo" : 2,
"hi" : 3
}] }
I get the following
Error - Unexpected token , in JSON at position 39.
I am very new to HTML and was wondering how I locate position 39 in order to try and find the error?
The second issue I am running into is that HTML displays the Donuts as I would expect in my Spotfire client but when I open the webplayer version the icons are not visible. I have to change tabs in the analysis and then return to the first page for the icons to appear. Is this likely to be an error in my HTML or an error elsewhere?
Thanks

In fact you have several problems,
-First you have to put all this code in one line otherwise "]" or "}" will make an error
-Second you have unexpected characters "<" and "/>" in your json you have to clean your json.
Then you can do in javascript
console.log(your_var)
or
console.log(JSON.parse(your_var))
it will transform in json you json (which is in string format)
We need sources to check what can be the problem.

Related

Not sure why I'm getting an error of "Value of property VPCSecurityGroups must be of type List of String"

I'm not sure why I'm getting the error that reads "Value of property VPCSecurityGroups must be of type List of String"
I've tried creating a db instance in cloud formation. The name of the security group is: wordpressDBSecurityGroup. I've tried passing the value to the db instance in the following ways:
I tried using FN::GetAtt
"VPCSecurityGroups" : {
"Fn::GetAtt":
[
"wordpressDBSecurityGroup",
"GroupId"]
}
I also tried hard coding the name into the attribute:
"VPCSecurityGroups": "wordpressDBSecurityGroup"
I also tried using the 'Ref' functionality:
"VPCSecurityGroups" : {"Ref": "wordpressDBSecurityGroup"}
Can anyone tell me why I'm getting this error? How should I be doing it?
I forgot to add the brackets to the ref functionality. This fixed the issue.
"VPCSecurityGroups" : [{"Ref": "wordpressDBSecurityGroup"}]

How to return number and newline with JSON

I want to return a number and a new line
{ data : "3
"}
But every time, I try to do this it is considered invalid
Update
My parser tool tries to do things with Newlines. Here is the complete screenshot:
** Update 2**
This is with jsonlint.com
The problem is that data is not a valid key (check https://www.json.org/ or Do the JSON keys have to be surrounded by quotes?), you need to use quotes for keys in order to have valid syntax. Also you need to add \n for a new line character:
{ "data": "3\n"}
I pasted this into the console without an error:
{ "data" : "3\n"}
Testing one step further:
a = { "data" : "3\n"}
a.data + "hello" // pasted into the console
produced this:
3
hello

Python: create json query

I'm trying to get python to create a json formatted like :
[
{
"machine_working": true
},
{
"MachineName": "TBL165-169",
"MachineType": "Rig Test"
}
]
However, i can seam to do it, this is the code i have currently but its giving me error
this_is_a_dict_too=[]
this_is_a_dict_too = dict(State="on",dict(MachineType="machinetype1",MachineName="MachineType2"))
File "c:\printjson.py", line 40
this_is_a_dict_too = dict(Statedsf="test",dict(MachineType="Rig Test",MachineName="TBL165-169")) SyntaxError: non-keyword arg after
keyword arg
this_is_a_dict_too = [dict(machine_working=True),dict(MachineType="machinetype1",MachineName="MachineType2")]
print(this_is_a_dict_too)
You are trying to make dictionary in dictionary, the error message say that you try to add element without name (corresponding key)
dict(a='b', b=dict(state='on'))
will work, but
dict(a='b', dict(state='on'))
won't.
The thing that you presented is list, so you can use
list((dict(a='b'), dict(b='a')))
Note that example above use two dictionaries packed into tuple.
or
[ dict(a='b'), dict(b='a') ]

OneNote Api - copyToNotebook hanging

The OneNote-Api recently started to hang on this call:
https://www.onenote.com/api/beta/me/notes/sections/{id}/copyToNotebook
Polling the result (as always) now returns the following
{
"#odata.context": "https://www.onenote.com/api/beta/$metadata#me/notes/operations/$entity",
"id": "copy-645387ea-eb06-4a0d-bcde-09d276e4e3d6fe0e14f6-3e53-421e-aa6c-8adcc998a4dd",
"status": "not started",
"createdDateTime": "2017-10-04T16:57:45.9599909Z",
"lastActionDateTime": "2017-10-04T16:57:45.9599909Z"
}
The lastActionDateTime never updates and the command doesn't complete despite returning the correct 202 code and subsequent 200 codes.
Any help would be appreciated (especially in a live working environment)!
You are calling the API correctly - we introduced a problem in our service a couple of days ago. This should be fixed now.
Thanks for reporting this. Feel free to report anything to us at: https://twitter.com/onenotedev?lang=en.
I performed the same operation and got back the same response. When checking my account to verify the copying worked I get back an error.
JSON object returned below. The copy file seems to be corrupted on OneNotes side.
{Responses: [[6,…]]}
Responses
:
[[6,…]]
0
:
[6,…]
0
:
6
1
:
{OperationId: 1, StatusCode: 126, RawCellStorageErrorCode: "InternalError.4", ServerPageStatsTrace: "",…}
AvailableFileAccess
:
1
CellId
:
"40c4a0be-3ff1-49c7-b169-ba9d74e0724c|1"
ContentBytes
:
0
ContextId
:
"null"
FileId
:
"WOPIsrc=https%3A%2F%2Fwopi%2Eonedrive%2Ecom%2Fwopi%2Ffiles%2F1438AEF7B187116%21122&access_token=4wfG%2D4rgaZ6xmefLfMpPpnlTOOxmBy0LNKwftRv4WQeE1YRkcD72ADoSfR%2DC2ZxSi11DuWIEGx0iSqZb8JP88aA36k2o8KKqF1hPyoFTblc3TyLt6k65eXe%2DL7QEcINnMhnvAA9aeuP5W2ttwIYE6dDJQVh9xkv5JcUndBG1d%5F3Ldp3%2DlcE3gNO7IEZtvzf7B0mUkKoerjtJr3OBKxsQzHx1PRCfh99BtCNPNvVVAq91thnpmeuVOATVGgWlMWcHTt29l9a8%2DrbHa3jknZWee6F6DBxU%5FzgW7YpWbZ4LtW1zOx33SQVm3XjRQ628TsgAV7%5Fy%2DJ4IvxCnGMVhpwvC%2DXLGnP35DAJW7LuetWKJ93B%5Fs&access_token_ttl=1510611198523"
OperationId
:
1
RawCellStorageErrorCode
:
"InternalError.4"
RevisionList
:
[]
RootCellId
:
"null"
ServerPageStatsTrace
:
""
StatusCode
:
126

How to user erlang gen_smtp to send html-formatted email?

gen_smtp can be found here
What I want is to let the content of email supports HTML tag, such as <strong>Hello</strong>
Will display as Hello.
Look at https://github.com/selectel/pat. It's an easy to use SMTP client and you can use any text, including html tags as body of the message.
See the gen_smtp mimemail tests for an example of multipart/alternative messages:
Email = {<<"text">>, <<"html">>, [
{<<"From">>, <<"me#example.com">>},
{<<"To">>, <<"you#example.com">>},
{<<"Subject">>, <<"This is a test">>}],
#{content_type_params => [
{<<"charset">>, <<"US-ASCII">>}],
disposition => <<"inline">>
},
<<"This is a <strong>HTML</strong> message with some non-ascii characters øÿ\r\nso there">>},
Encoded = mimemail:encode(Email)
The answer given by #Ward Bekker is fundamentally correct but it took me a while to make it work as the mimemail:encode/1 expects a proplist not a map which the example shows.
I used Erlang Erlang/OTP 23 [erts-11.0.3] and it failed with:
** exception error: no function clause matching proplists:get_value(<<"content-type-params">>, #{disposition => <<"inline">>,<<"content-type-params">> => [{<<"charset">>,<<"US-ASCII">>}]},[]) (proplists.erl, line 215)
in function mimemail:ensure_content_headers/7 (/Users/sean/Documents/code/erlang/scofblog/_build/default/lib/gen_smtp/src/mimemail.erl, line 661)
The following is the modified code and the encoded output:
Email = {
<<"text">>,
<<"html">>,
[
{<<"From">>, <<"me#example.com">>},
{<<"To">>, <<"you#example.com">>},
{<<"Subject">>, <<"This is a test">>}
],
[{<<"content-type-params">>, [{<<"charset">>, <<"US-ASCII">>}]},
{<<"disposition">>, <<"inline">>}
],
<<"This is a <strong>HTML</strong> øÿ\r\nso there">>
}.
62> mimemail:encode(Email).
<<"From: me#example.com\r\nTo: you#example.com\r\nSubject: This is a test\r\nContent-Type: text/html;\r\n\tcharset=US-ASCII\r\nCon"...>>
Hope that saves some head scratching.