postgresql – PSQL: Multiple lines against single lines with JSON

What is the best way to do this?

  • On the TV show page, I have to get all the progress from all episodes in this TV show
  • I have to get continue_watching on the homepage
  • In Episode, I have to progress the episode.
  • Some TV shows have more than 100 episodes

Ex:

USER_ID | SHOW_ID | LAST_SEEN_ID | LAST_SEEN_TIME
10      | 5       | 12           | ---

USER_ID | EPISODE_ID | PROGRESS
10      | 10         | 15
10      | 11         | 20
10      | 12         | 95

OR

USER_ID | SHOW_ID | PROGRESS                     | LAST_SEEN_ID | LAST_SEEN_TIME
10      | 5       | {"10":15, "11":20, "12": 95} | 12           | ---

In posgresql I can get the individual progress with:

SELECT progress -> & # 39; 10 & # 39; as progress …

I think the best method is the first one, but it will produce many lines and this could slow the DB down?

node.js – Escaping random ASCII characters in JSON

I am concerned with the current situation. I work in NodeJS and receive a string from an external API, for example "monção", and when I try to send it to the client it gets something instead of "çã".

I know I have to convert "monção" to "mon u00e7 u00e3o" But I'm excited to find a way to properly escape this string, knowing that this string can be any text.
Anyone know to solve that anyway?

Thanks a lot

Python – how to convert a multi-valued JSON into a data frame

How do I work with multi-valued Json on Pandas or Numpy?
I have a JSON in the following format

  (
  "livro": "A guerra",
  "autores": {
        "Josestenne": {
            "universidade": "UNIVERSIDADE FEDERAL DO CEARÁ (UFC)",
            "departamento": "Faculdade de Economia, Administração, Atuária e Contabilidade"
        },
        "Augusto": {
            "universidade": "UNIVERSIDADE FEDERAL DO CEARÁ (UFC)",
            "departamento": "Faculdade de Economia, Administração, Atuária e Contabilidade"
        },
        "Sandra": {
            "universidade": "UNIVERSIDADE FEDERAL DO CEARÁ (UFC)",
            "departamento": "Faculdade de Economia, Administração, Atuária e Contabilidade"
        }
    }
    )

How can I transform this object within the pandas, for example to count the authors of the books? or the greatest authors of all books?

modern experience – resizing an image with the formatting of the json iist view

I'm trying to replicate the look of the news.aspx page for a custom view:

Enter the image description here

To make sure that the thumbnail keeps its aspect ratio when resizing, I decided to add the same method used on the news.aspx page: wrap the image in a width and height div and use that Object adjustment to resize the image:

"children": (
                {
                      "elmType": "div",
                      "style": {                           
                        "width": "276px",
                        "height":"154px"                            
                      },
                      "children": (
                        {
                          "elmType": "img",
                          "style": {
                            "display": "block",
                            "opacity":" 1",
                            "width": "100%",
                            "height": "100%",
                            "object-fit": "cover",
                            "position": "absolute",
                            "left": "50%",
                            "top": "50%",
                            "transform":" translate(-50%, -50%)"

                          },
                          "attributes": {
                            "src": "($BannerImageUrl)"
                          }
                        }
                      )
                    },

This just blows up the pictures and creates a mess. Can anyone confirm if this looks right before I start over?

Here is the full JSON (the elements below are not yet filled with anything):

{
"schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
"debugMode": false,
"hideSelection": true,
"hideColumnHeader": true,
"rowFormatter": {
  "elmType": "div",
  "attributes": {
    "class": "ms-borderColor-neutralLight"
  },
  "style": {
    "flex-direction": "column",
    "align-items": "stretch",
    "box-sizing": "border-box",
    "border-width": "1px",
    "border-left-width": "1px",
    "border-style": "solid"
  },
  "children": (
    {
      "elmType": "div",
      "style": {
        "display": "flex",
        "flex-wrap": "wrap",
        "align-items": "center",
        "box-sizing": "border-box",
        "padding": "0"
      },
      "children": (
        {
          "elmType": "div",
          "style": {
            "flex": " "
          },
          "children": (
            {
              "elmType": "div",
              "style": {
                "width": "276px",
                "height":"154px"
              },
              "attributes": {
                "class": "ms-NewsPinningItemImage"
              },
              "children": (
                {
                      "elmType": "div",
                      "style": {                           
                        "width": "100%",
                        "height":"100%"                            
                      },
                      "children": (
                        {
                          "elmType": "img",
                          "style": {
                            "display": "block",
                            "opacity":" 1",
                            "width": "100%",
                            "height": "100%",
                            "object-fit": "cover",
                            "position": "absolute",
                            "left": "50%",
                            "top": "50%",
                            "transform":" translate(-50%, -50%)"

                          },
                          "attributes": {
                            "src": "($BannerImageUrl)"
                          }
                        }
                      )
                    },

                {
                  "elmType": "a",
                  "attributes": {
                    "class": " ",
                    "target": "_blank",
                    "href": "($FileRef)"
                  },
                  "style": {
                    "line-height": "1.5em",
                    "margin": "8px 0",
                    "font-size": "21px",
                    "font-weigth": "300",
                    "padding-left": "18px",
                    "padding-right": "10px",
                    "font-family": "Segoe UI Light",
                    "color": "#999",
                    "text-decoration": "none",
                    "display": "block"
                  },
                  "txtContent": "($Title)"
                },
                {
                  "elmType": "span",
                  "attributes": {
                    "class": "ms-font-xl"
                  },
                  "style": {
                    "line-height": "1.5em",
                    "color": "gray",
                    "margin": "8px 0",
                    "font-size": "15px",
                    "font-family": "Helvetica",
                    "display": "block"
                  },
                  "txtContent": "($Description)"
                },
                {
                  "elmType": "span",
                  "attributes": {
                    "class": "ms-font-xl"
                  },
                  "style": {
                    "line-height": "1.5em",
                    "color": "gray",
                    "margin": "8px 0",
                    "font-size": "15px",
                    "font-family": "Helvetica"                      
                  },
                  "txtContent": "($Author.title)"
                },
                {
                  "elmType": "span",
                  "attributes": {
                    "class": "ms-font-xl"
                  },
                  "style": {
                    "line-height": "1.5em",
                    "color": "gray",
                    "margin": "8px 0",
                    "margin-left": "8px",
                    "font-size": "12px",
                    "font-family": "Helvetica"
                  },
                  "txtContent": "($FirstPublishedDate)"
                },
                {
                  "elmType": "span",
                  "attributes": {
                    "class": "ms-font-xl"
                  },
                  "style": {
                    "line-height": "1.5em",
                    "color": "gray",
                    "margin": "8px 0",
                    "margin-left": "8px",
                    "font-size": "15px",
                    "font-family": "Helvetica"
                  },
                  "txtContent": ""
                },
                {
                  "elmType": "div",
                  "attributes": {
                    "class": "ms-font-m"
                  },
                  "style": {
                    "line-height": "1.5em",
                    "margin": "8px 0"
                  },
                  "children": (
                    {
                      "elmType": "div",
                      "style": {
                        "margin-left": "85px"
                      },
                      "children": (
                        {
                          "elmType": "div",
                          "txtContent": ""
                        }
                      )
                    }
                  )
                }
              )
            }
          )
        }
      )
    },
    {
      "elmType": "div",
      "style": {
        "padding": "4px 88px",
        "line-height": "1.5em",
        "display": "flex",
        "justify-content": "space-between"
      },
      "children": (
        {
          "elmType": "span",
          "children": (
            {
              "elmType": "span",
              "style": {
                "vertical-align": "bottom",
                "margin": "0 9px 0 1px"
              },
              "attributes": {
                "iconName": ""
              }
            },
            {
              "elmType": "span",
              "txtContent": ""
            },
            {
              "elmType": "a",
              "style": {
                "vertical-align": "bottom",
                "margin": "0 9px 0 20px"
              },
              "attributes": {
                "iconName": "",
                "target": "_blank",
                "href": ""
              }
            }
          )
        }
      )
    }
  )
}

}}

PHP – Ajax Json [object Object] Transfer of web sockets variable

I receive data from a PHP via AJAX and have to send it to another JS.

PHP:

$arrayjson() = array(
    'id_pedido'          => $peid,
    'id_cliente'         => $clienteactual,
    'fechaservicio'         => $FechaServicioUP,
);
$OK= 'Pedido insertado.  Pedido Nº '.$id_pedido_nuevo.'';
$datos_a_enviar = array($OK, $arrayjson);
echo json_encode($datos_a_enviar);

When I get them in AJAX, they look correct.

AJAX:

var dataString = $('#PedidoDeCliente').serialize();

// Enviamos el formulario usando AJAX
    $.ajax({
       type: "POST",
        url: "pedidos_clientes_insert.php",
        data: dataString,
        dataType: "json",
        async: true,

 beforeSend: function(){      
 $("#ResultadosDeMovimientos").html("

"); }, error: function(data){ $("#ResultadosDeMovimientos").html("Error al insertar datos. Intente nuevamente."+data); }, success: function(data) { datoA = data(0); datoB = data(1); if(datoA == "ERROR"){ $('#ResultadosDeMovimientos').html(datoB); }else{ console.log(datoB); send(datoB);// array JSON para socket $('#ResultadosDeMovimientos').html(datoA); } } });

The result of console.log(datoB); is

({…})0: id_pedido: "ped_5c74110a85680"id_pedido_trafico: 39192id_cliente: "3"fechaservicio: "2020-03-28"horaservicio: "23:24"tiposervicio: "2"

Here I send to JS, from send(datoB); into the file ancywebsocket.js

ancywebsocket.js:

var FancyWebSocket = function(url)
{
	var callbacks = {};
	var ws_url = url;
	var conn;
	
	this.bind = function(event_name, callback)
	{
		callbacks(event_name) = callbacks(event_name) || ();
		callbacks(event_name).push(callback);
		return this;
	};
	
	this.send = function(event_name, event_data)
	{
		this.conn.send( event_data );
		return this;
	};
	
	this.connect = function() 
	{
		if ( typeof(MozWebSocket) == 'function' )
		this.conn = new MozWebSocket(url);
		else
		this.conn = new WebSocket(url);
		
		this.conn.onmessage = function(evt)
		{
			dispatch('message', evt.data);
			
		};

		this.conn.onclose = function(){dispatch('close',null)}
		this.conn.onopen = function(){dispatch('open',null)}
	};
	
	this.disconnect = function()
	{
		this.conn.close();
	};
	
	var dispatch = function(event_name, message)
	{
		if(message == null || message == "")
			{
			}
			else
			{
		console.log(message);

				
        actualiza_mensaje(message);
				
				
			}
	}
};

var Server;
function send( text ) 
{
    Server.send( 'message', text );
}
$(document).ready(function() 
{
	Server = new FancyWebSocket('ws://localhost:12345');
    Server.bind('open', function()
	{
    });
    Server.bind('close', function( data ) 
	{
    });
    Server.bind('message', function( payload ) 
	{
    });
    Server.connect();
});



function actualiza_mensaje(message)
{
	console.log(message);
			
}

Here is the result of console.log(message); is (object Object)
Therefore, I cannot process the data that the variable contains.

I've already tried:

        var JSONdata    = JSON.parse(message);
				var id_pedido = JSONdata(0).id_pedido;
				var id_cliente = JSONdata(0).id_cliente;
				var fechaservicio = JSONdata(0).fechaservicio;
				
        console.log(id_pedido);
        console.log(id_cliente);
        console.log(fechaservicio);

The result is Undefined variable

I also tried it

$.each(JSON.parse(message), function (index, item) {
					var id_pedido = item.id_pedido_trafico;
					var id_cliente = item.id_cliente;
					var fechaservicio = item.fechaservicio;

          console.log(id_pedido);
          console.log(id_cliente);
          console.log(fechaservicio);
});	

And the result is

jquery-3.3.1.min.js:2 Uncaught TypeError: Cannot use 'in' operator to search for 'length' in (object Object)
at C (jquery-3.3.1.min.js:2)
at Function.each (jquery-3.3.1.min.js:2)
at dispatch (fancywebsocket.js:63)
at WebSocket.conn.onmessage (fancywebsocket.js:29)

Javascript – Spotify API – JSON returns undefined, but I can still console.log ()

I'm trying to use Spotify's Web Player API to get the & # 39; device_id & # 39; to access. According to the documents, the server-side API call I made should return a & # 39; payload that contains device objects & # 39; like the following:

This is my API call:

app.get('/c+party', (req,res)=>{
    const access_token = req.query.access_token;
    var device_id;
    var options = {
        url: 'https://api.spotify.com/v1/me/player/devices',
        headers: {
            'Authorization': 'Bearer '+ access_token,
            'Content-Type':'application/json'
        },
        json:true
    };
    request.get(options, (err,response,body) => {
        const device_id = body.devices(0).id;
        res.end();
    });
});

It should return:

{
  "devices" : ( {
    "id" : "5fbb3ba6aa454b5534c4ba43a8c7e8e45a63ad0e",
    "is_active" : false,
    "is_private_session": true,
    "is_restricted" : false,
    "name" : "My fridge",
    "type" : "Computer",
    "volume_percent" : 100
  } )
}

I can use console.log (body) to see the output I want, but I really can't access the value I want. When my code runs, I get an error that body.devices is undefined. I'm also pretty sure Spotify is giving me a JSON object properly because JSON.parse (body) returns an unexpected token error. Help with a solution? I am brand new with express.js – does my routing mess this up?

json – How is the persona card displayed in the list when hovering using the Sharepoint Online view formatting?

If you can hover over someone's name in an unformatted Sharepoint list to get more information about them, I think it's called a Persona Card. How can I keep this functionality after formatting my list with JSON?

For the following example, I would like each of the person names from the PastMembers field to have this hover action when it is displayed.

{
  "elmType": "div",
  "forEach": "person in [$PastMembers]",
  "children": [
    {
      "elmType": "div",
      "txtContent": "[$person.title]"
    }
  ]
}

json rpc – How could the Softforks field that provides the RPC command getblockchaininfo be useful?

When I run the getblockchaininfo command, useful information is displayed, but I don't understand how the information that is displayed through field softforks can be useful. The following example shows:
bitcoin-cli getblockchaininfo
{
"Chain": "main",
"Blocks": 623195,
"Header": 623195,
"bestblockhash": "00000000000000000010596cbf2767824bbb4828b331f2533938f1650ba96202",
"Difficulty": 13912524048945.91,
"mediantime": 1585317240,
"Verification progress": 0.9999826836456495,
"initialblockdownload": false,
"Chain work": "0000000000000000000000000000000000000000000df5647c802d85a8d1fea0b0",
"size_on_disk": 305751602545,
"cropped": wrong,
""Softforks": {
"bip34": {
"Type": "buried",
"active": true,
"Height": 227931
},
"bip66": {
"Type": "buried",
"active": true,
"Height": 363725
},
"bip65": {
"Type": "buried",
"active": true,
"Height": 388381
},
"csv": {
"Type": "buried",
"active": true,
"Height": 419328
},
"segwit": {
"Type": "buried",
"active": true,
"Height": 481824
}}
},
"Warnings": ""
}}

json rpc – How can I run getnewaddress on my full node from a remote server?

I have a full knot running on a digital ocean droplet. I have an app at Heroku and I want to run it getnewaddress from this app. I'm trying to generate BTC addresses that users can send payments to for payment processing in my app. How can I do that? Thank you in advance.

My app is in python, for what it's worth.