<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with loadjsonarray() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=loadjsonarray%28%29</link>
      <pubDate>Sun, 08 Aug 2021 19:03:39 +0000</pubDate>
         <description>Tagged with loadjsonarray() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedloadjsonarray%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>how do i trigger video without it freezing?</title>
      <link>https://forum.processing.org/two/discussion/26056/how-do-i-trigger-video-without-it-freezing</link>
      <pubDate>Sun, 21 Jan 2018 11:15:57 +0000</pubDate>
      <dc:creator>luketaylor96</dc:creator>
      <guid isPermaLink="false">26056@/two/discussions</guid>
      <description><![CDATA[<p>Hey guys, i am currently working on a project where i need to read a database once to store a specific word in a variable, trigger a video to play and then repeat. However i can load the database in and pick out that specific word but when i get to the triggering it is like it plays one frame of the video and then freezes until the next repeat, I can't seem to solve this and some help would be great. Ill post my code below.</p>

<pre><code>import processing.video.*;
Movie joyMov, sadnessmMov, angerMov, fearMov, analyticalMov, confidentMov, tentativeMov;
JSONArray values;

String mLab = "";

String Joy = "Joy";
String Fear = "Fear";
String Anger = "Anger";
String Sadness = "Sadness";
String Analytical = "Analytical";
String Confident = "Confident";
String Tentative = "Tentative";
String tone1;

void setup() {
  size(640, 360);
  //fullScreen();
  //surface.setResizable(true);
  background(0);
  frameRate(30);
  joyMov = new Movie(this, "joy.mp4");
  sadnessmMov = new Movie(this, "");
  angerMov = new Movie(this, "");
  fearMov = new Movie(this, "");
  analyticalMov = new Movie(this, "");
  confidentMov = new Movie(this, "");
  tentativeMov = new Movie(this, "");
  joyMov.loop();
}

void draw() {

  float count = frameCount % 150;
  if (count == 0) { 
   readDB();
   println(tone1);
   if(tone1.equals(Joy) == true) {
     println("the tone is: Joy");
     playJoyMov();
   } else if(tone1.equals(Anger) == true) {
     println("the tone is: Anger");
   } else if(tone1.equals(Sadness) == true) {
     println("the tone is: Sadness");
   } else if(tone1.equals(Fear) == true) {
     println("the tone is: Fear");
   } else if(tone1.equals(Analytical) == true) {
     println("the tone is: Analytical");
   } else if(tone1.equals(Confident) == true) {
     println("the tone is: Confident");
   } else if(tone1.equals(Tentative) == true) {
     println("the tone is: Tentative");
   }
  }
}

void readDB(){
  //load json from mlabs db
  values = loadJSONArray(mLab);
      //println(values[values.size()]);

  //for (int i = 0; i &lt; values.size(); i++) {

    JSONObject tweet = values.getJSONObject(values.size()-1);
    println(tweet);

    //String location = tweet.getString("location");
    //String text = tweet.getString("tweet");
    //tone = tweet.values.getString("tone");
    tone1 = tweet.getString("tone");
    //println(location + " | " + text + " | " + tone);

  //}
}

void movieEvent(Movie m) {
  m.read();
}

void playJoyMov() {
  image(joyMov, 0, 0, width, height);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>loadJSONArray immediately failing on Android build</title>
      <link>https://forum.processing.org/two/discussion/25003/loadjsonarray-immediately-failing-on-android-build</link>
      <pubDate>Tue, 14 Nov 2017 12:05:10 +0000</pubDate>
      <dc:creator>precociousmouse</dc:creator>
      <guid isPermaLink="false">25003@/two/discussions</guid>
      <description><![CDATA[<p>Hi all! I am working on a little project which makes a request for a JSON array from an external server based on a lat/long pairing. The app compiles ok without errors, and runs ok on the device, but when I tap to make the request it immediately crashes.</p>

<p>I made a change to push the lat/long to the screen and that is functioning ok, and I am casting the lat/long to strings to construct the URL ok, but I am now just a bit stuck why it should just fall over when just trying to push the loadJSONArray request to a JSONArray var.</p>

<p>Any thoughts?</p>
]]></description>
   </item>
   <item>
      <title>Problem attempting to create a large 2D array from a JSON</title>
      <link>https://forum.processing.org/two/discussion/23045/problem-attempting-to-create-a-large-2d-array-from-a-json</link>
      <pubDate>Tue, 13 Jun 2017 02:33:51 +0000</pubDate>
      <dc:creator>kiefac</dc:creator>
      <guid isPermaLink="false">23045@/two/discussions</guid>
      <description><![CDATA[<p>I'm working on a personal project that will render a low-quality (32x32) heightmap as 3D terrain. I'm having issues loading the terrain file, which I've defined as a JSON file with a particular format, as a big 2D array. I'm probably doing many things horribly wrong (especially loading array elements from a JSON), please help me...</p>

<p>JSON object format:</p>

<pre><code>{
  "row": 0,
  "data": [ -128, -109, -70, ... 30, 102 ]
},
</code></pre>

<p>There's 32 of them labeled 0 to 31, and each "data" array has 32 values ranging from -128 to 127. I've verified that the JSON is valid.</p>

<p>Code:</p>

<pre><code>JSONArray rawHeight;
byte[][] hmap = null;
byte[] temp = null;

void prepareHMapAndTemp() {
  for (int h = 0; h &lt; 32; h++) {
    hmap[i] = new byte[32];
    temp[i] = new byte;
  }
}

void processHeightData() {
  for (int i = 0; i &lt; 32; i++) {
    JSONObject row = rawHeight.getJSONObject(i);

    for (int j = 0; j &lt; 32; j++) {
      temp = (byte[])append(hmap, row.getJSONObject("data").getInt(j));
    }
    hmap = (byte[][])append(hmap, temp);

    println(i + ": " + row);
  }
}

void setup() {
  rawHeight = loadJSONArray("map.hmp");
  prepareHMapAndTemp();
  processHeightData();
}
</code></pre>

<p>On <code>temp[i] = new byte;</code>, <code>byte;</code> is underlined and gives this very ambiguous error: <code>Error on "Dimensions"</code>. Trying to run it anyways has it yelling <code>unexpected token ";"</code>. Also, <code>temp = (byte[])append(hmap, row.getJSONObject("data").getInt(j));</code> gives the error <code>The function "getInt()" expects parameters like: "getInt(String)"</code> even though the online reference says it takes an int for the index?</p>

<p>Edit: Just realized I was I started hmap without a value and temp with a value of null. Now both are be started as null. Don't think there's actually a difference, though.</p>
]]></description>
   </item>
   <item>
      <title>coordinates Data to pixels</title>
      <link>https://forum.processing.org/two/discussion/17038/coordinates-data-to-pixels</link>
      <pubDate>Wed, 08 Jun 2016 09:18:54 +0000</pubDate>
      <dc:creator>uness</dc:creator>
      <guid isPermaLink="false">17038@/two/discussions</guid>
      <description><![CDATA[<p>I try to get the longitude and latitude of the earth quack on the <a rel="nofollow" href="https://en.wikipedia.org/wiki/Iceland#/media/File:Map_of_Iceland.svg">map </a>but i get a weird values, can someone help me figure out what i'm doing wrong?</p>

<p>I get the following values, which are outside my canvas:</p>

<p>Example of the Json data:</p>
]]></description>
   </item>
   <item>
      <title>Joining 2 JSON output into 1 String</title>
      <link>https://forum.processing.org/two/discussion/16805/joining-2-json-output-into-1-string</link>
      <pubDate>Tue, 24 May 2016 18:29:30 +0000</pubDate>
      <dc:creator>iProcessor</dc:creator>
      <guid isPermaLink="false">16805@/two/discussions</guid>
      <description><![CDATA[<p>Hi all!</p>

<p>I have Processing read from a PHP file</p>

<pre><code>[{“ID”:”1”,”Name”:”Adam”},
 {“ID”:”2”,”Name”:”Peter”}]                                                                                                                      
</code></pre>

<p>I then give them a</p>

<pre><code>    "String ID = value.getString("ID");"
    "String Name = value.getString("Name");"
</code></pre>

<p>println(ID+Name);</p>

<p>Will give me</p>

<p>123456Adam<br />
456Peter</p>

<p>How do I join them in one string and print in such that</p>

<p>123456Adam456Peter?</p>

<p>Thanks alot in advance!</p>
]]></description>
   </item>
   <item>
      <title>Nullpointer exception Array</title>
      <link>https://forum.processing.org/two/discussion/16106/nullpointer-exception-array</link>
      <pubDate>Tue, 19 Apr 2016 20:00:44 +0000</pubDate>
      <dc:creator>shirinmalina</dc:creator>
      <guid isPermaLink="false">16106@/two/discussions</guid>
      <description><![CDATA[<p>Hello everybody, 
I am pretty new to processing, and just ran into the following problem</p>

<p>I am importing values from a json file, and when I run the following code I get a Nullponter Exception error.
I googled and tried different things, but unfortunately I cannot solve the problem.
I am greatful for any help, here is my code:</p>

<pre><code>JSONObject json;
int max;
void setup() {
  size(841,594);

JSONArray jsonArray = loadJSONArray("january_2016.json");
JSONObject jsonObject = jsonArray.getJSONObject(0); 
JSONObject maxTemperature = json.getJSONObject("Max Temperature");
int max = maxTemperature.getInt("max");

  print(max);
}

void draw(){
//Max Temperature  
  textAlign(CENTER);
  text("Max Temperature",841/4, 594/2+100);

  ellipseMode(RADIUS);
  ellipse(841/4, 594/2, max, max); // max
  ellipse(841/4, 594/2, max, max); //avg
  ellipse(841/4, 594/2, max, max); //min

}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Can't find the problem with some code, but it won't run.</title>
      <link>https://forum.processing.org/two/discussion/15794/can-t-find-the-problem-with-some-code-but-it-won-t-run</link>
      <pubDate>Thu, 31 Mar 2016 23:47:04 +0000</pubDate>
      <dc:creator>legowerewolf</dc:creator>
      <guid isPermaLink="false">15794@/two/discussions</guid>
      <description><![CDATA[<p>I've gone over this a few times. Processing is reporting "Found one too many { characters without a } to match it." I count exactly twenty "{" and the same number of "}". Help?</p>

<p>EDIT: I put all my classes in different tabs. This is the tab Processing opened when I got the error.</p>

<p><code>public class Server
{
  private JSONObject data;
  private String name;
  private String status;
  private int port;
  private boolean shared;
  private String publicURL;
  public Server(String newName)
  {
    name = newName;
    refreshData();
  }
  //Getting----------------------
  public String getName() {
    return name;
  }
  public String getStatus() {
    return status;
  }
  public String getPublicUrl() {
    return publicURL;
  }
  public String toString() {
    return data.toString();
  }
  //Misc-------------------------
  public void refreshData()
  {
    JSONArray servers = null;
    try {
      servers = loadJSONArray("<a href="http://127.0.0.1:33649/server/list" target="_blank" rel="nofollow">http://127.0.0.1:33649/server/list</a>");
    }
    catch (Exception e1)
    {
      launch("C:\\ProgramData\\Fenix\\Fenix.exe");
      while (servers==null)
      {
        try {
          servers = loadJSONArray("<a href="http://127.0.0.1:33649/server/list" target="_blank" rel="nofollow">http://127.0.0.1:33649/server/list</a>");
        }
        catch (Exception e2)
        {
        }
      }
    }
    for (int i = 0; i&lt;servers.size(); i++)
    {
      JSONObject temp = servers.getJSONObject(i);
      if (temp.getString("name").equals(name))
      {
        data = temp;
      }
    }
    if (data.getBoolean("starting"))
    {
      status = "Starting";
    } else if (data.getBoolean("stopping"))
    {
      status = "Stopping";
    } else if (data.getBoolean("running"))
    {
      status = "Running";
    } else 
    {
      status = "Stopped";
    }
    port = data.getInt("port");
    if (data.getBoolean("shared"))
    {
      shared = true;
      publicURL = data.getString("publicUrl");
    } else
    {
      shared = false;
      publicURL = null;
    }
  }
}</code></p>
]]></description>
   </item>
   </channel>
</rss>